R 中的参数、绘图、输出和最佳拟合线
我在处理 R 中的一些数据时有几个问题:
我正在使用以下语句:detailsTable <- read.table(file=commandArgs()[6], header=TRUE, col.names=c(" a", "b", "c", "d", "e")) 似乎该表没有正确加载...但是如果我明确指定要加载的文件的路径,那么一切都会进行出色地。我做错了什么?
我绘制了上述表格中包含的数据。如何将绘图(例如:plot.savePDF("plot.pdf"))保存到 PDF 文件?
如何将 cor(detailsTable$a,detailsTable$b) 的输出重定向到文件?以及如何将一个简单的字符串写入文件。例如:“数据的相关性:” + cor(...)
如何在现有图上绘制最佳拟合线?
所有这些都在 R 中。
非常感谢任何可以提供帮助的人,
ExtremeCoder
I have several questions to do with handling some data in R:
I am using this statement: detailsTable <- read.table(file=commandArgs()[6], header=TRUE, col.names=c("a", "b", "c", "d", "e")) and it seems that the table is not being loaded correctly... but if I specify the path of the file I am loading excplicitly then all goes well. What am I doing wrong?
I plot the data contained in that table mentioned above. How do I save the plot (eg: plot.savePDF("plot.pdf")) to a PDF file?
How could I redirect the output of, for example, cor(detailsTable$a, detailsTable$b) to a file? and how do I write a simple string to a file. eg: "Correlation of the data: " + cor(...)
How do I plot the line of best fit on an existing plot?
All of this is in R.
Many thanks to anyone who can help,
ExtremeCoder
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
检查
write.table
手册页 (?write.table
)check the
write.table
manual page (?write.table
)您可以使用sink()重定向输出。
You can redirect output using
sink().
如何保存您正在生成的绘图取决于您使用的绘图系统。假设它是基本图形,您需要启动 pdf 图形设备,然后绘制到它。
How to save the plot you're producing depends on which plotting system you're using. Assuming it's base graphics, you need to start a pdf graphics device, then plot to it.