Extracting Data From a Figure using R

To extract data from a jpg file in R using the digitize package:

  1. save image as a *.jpg file
  2. open R
  3. change the directory that R is using to the one where the image is
  4. use R code below to extract data, display it, and save it in a csv file steps below
  5. upload csv to the project file in google spreadsheet, or open as excel/openoffice and copy/paste to google spreadsheet

library('digitize')
calpts <- ReadAndCal('authorYYYabc_fixX.jpg') 
   ## click on xaxis min (x1), xaxis max (x2), 
   ## yaxis min(y1), yaxis max (y2)
pts <- DigitData(col='red',type='p',n=8)
   ## set n = to the number of points to collect 
data <- Calibrate(pts, calpts, x1, x2, y1, y2)
   ## x1, x2, y1, and y2 are the min and max of the x and y axes, respectively.
print(data)
write.csv(data, 'authorYYYYabc_figX.csv')



David 2011-10-07