Dear R forum I have one stupid question, but I have no other solution to it in sight? Suppose some R process creates graphs etc alongwith main output as data.frame e.g output1 = data.frame(bands = c("A", "B", "C"), results = c(74, 108, 65)) I normally save this output as some csv file. But I need to save this output as some image (I understand this is weird, but I need to find out some way to do so) e.g. for graph, I use 'png' as png("histogram.png", width=480,height=480) ..................... .................. dev.off() Please advise. Regards Katherine [[alternative HTML version deleted]]
do you want to save the dataframe used in the plot and then the plot itself? If so consider using 'lattice' or 'ggplot2' which create an object for "print" and this would allow you to use 'save' to save both objects in a file. If you want to generate the 'png' file, the you would have to 'save' the dataframe and then 'zip' the .RData and png file into a new file. So what is it that you intend to do with the data that is saved in the common file? On Fri, Dec 21, 2012 at 8:59 AM, Katherine Gobin <katherine_gobin at yahoo.com> wrote:> Dear R forum > > I have one stupid question, but I have no other solution to it in sight? > > Suppose some R process creates graphs etc alongwith main output as data.frame e.g > > output1 = data.frame(bands = c("A", "B", "C"), results = c(74, 108, 65)) > > I normally save this output as some csv file. > > But I need to save this output as some image (I understand this is weird, but I need to find out some way to do so) e.g. for graph, I use 'png' as > > png("histogram.png", width=480,height=480) > > ..................... > > .................. > > dev.off() > > Please advise. > > Regards > > Katherine > > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it.
Hi Katherine, You could try this: library(plotrix) png("katherine.png") ?plot(0:3,0:3,xlab="",ylab="",type="n",axes=FALSE) ?addtable2plot(1,1,output1,cex=2) ?dev.off() A.K. ----- Original Message ----- From: Katherine Gobin <katherine_gobin at yahoo.com> To: r-help at r-project.org Cc: Sent: Friday, December 21, 2012 8:59 AM Subject: [R] Can data.frame be saved as image? Dear R forum I have one stupid question, but I have no other solution to it in sight? Suppose some R process creates graphs etc alongwith main output as data.frame e.g output1 = data.frame(bands = c("A", "B", "C"), results = c(74, 108,? 65)) I normally save this output as some csv file. But I need to save this output as some image (I understand this is weird, but I need to find out some way to do so) e.g. for graph, I use 'png' as png("histogram.png", width=480,height=480) ..................... .................. dev.off() Please advise. Regards Katherine ??? [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -------------- next part -------------- A non-text attachment was scrubbed... Name: katherine.png Type: image/png Size: 4972 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121221/adf4455f/attachment-0002.png>