简体   繁体   English

将图表转换为R中的数据框架

[英]Convert a Graph to a Data Frame in R

So a while back (6 months+) I saw a blog post where the author took a line graph someone had posted on the internet, fed the image into R, and used a function to convert the image into a data frame. 不久前(6个月以上),我看到一篇博文,其中作者拍摄了某人在互联网上发布的折线图,将图像输入到R中,并使用函数将图像转换为数据框。

I've looked everywhere, and I can't seem to find this blog post (even though I'm sure I bookmarked it). 我到处寻找,我似乎无法找到这篇博文(即使我确定我已将它加入书签)。 So I was wondering if any of you had also read said blog post, or if someone knew of a quick and easy way to convert a line graph to a data frame in R? 所以我想知道你们是否也读过这篇博文,或者有人知道一种快速简便的方法将线图转换为R中的数据框?

Was this it? 是吗? I searched for "R digitize plot". 我搜索了“R数字化情节”。 The package used is " ReadImages ". 使用的包是“ ReadImages ”。 For completeness, the steps listed were (see link): 为了完整起见,列出的步骤是(见链接):

library(ReadImages) #Load package
mygraph <- read.jpeg('plot.jpg') #Import image
plot(mygraph) # Plot the image
calpoints <- locator(n=4,type='p',pch=4,col='blue',lwd=2) # Calibrate the plot by selecting known coordinates
data <- locator(type='p',pch=1,col='red',lwd=1.2,cex=1.2) # Collect the data points in a dataframe

When you say 'the image as a data frame', do you mean you want to get back to the original data that made the line? 当你说'图像作为数据框'时,你的意思是你想要回到制作该线的原始数据吗?

It's not R, but I've used Engauge Digitizer for this sort of thing: 它不是R,但我使用了Engauge Digitizer来做这种事情:

http://digitizer.sourceforge.net/ http://digitizer.sourceforge.net/

As i write this, the digitize package and the ReadImages package are no longer available for R 3.0.2. 在我写这篇文章时,R 3.0.2不再提供数字化包和ReadImages包。 Engauge Digitizer is a good option but if you still want to do this sort of thing in R, take a loook at http://rscriptsandtips.blogspot.no/ Engauge Digitizer是一个不错的选择,但是如果你仍想在R中做这类事情,那就去http://rscriptsandtips.blogspot.no/吧。

Also look at the updateusr function in the TeachingDemos package. 另请参阅TeachingDemos包中的updateusr函数。 Once you have the image displayed as in Benjamin's post, you can use the updateusr function with the known points to change the user coordinates so that then the results from the locator function do not need any additional transformation. 在Benjamin的帖子中显示图像后,您可以使用带有已知点的updateusr函数来更改用户坐标,以便定位器函数的结果不需要任何其他转换。

You can also use im2graph to convert graphs to data. 您还可以使用im2graph将图形转换为数据。 It's free and available of Windows and Linux ( http://www.im2graph.co.il ). 它是免费的,可用于Windows和Linux( http://www.im2graph.co.il )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM