I just have a simple question. I'm using the predict function, and I get about 1000 values. Now, how would I make it into a data frame or a list so that I can easily use Excel to graph the data? Right now, it's in horizontal lines, and it would be a pain to copy and paste and make it into a vertical column. Thanks! -- View this message in context: http://www.nabble.com/simple-question-about-exporting-data...-tp24620281p24620281.html Sent from the R help mailing list archive at Nabble.com.
Hi Strange. Before starting with R about 10 years ago I used Excel for for graphing too. As soon as I learned few tricks and read intro documents I abandoned Excel for graphing almost completely. Now even for simple visualisations of data I copy them ***from*** spreadsheet to R. But as you make your bed you must lie in it. Here is simple function to transfer data frame or vector by Ctrl-V approach write.excel <- function (tab) write.table(tab, "clipboard", sep = "\t", row.names = F) Issue write.excel(1:10) in R and in spreadsheet press Ctrl-V. Even with this simple vector you will get a column in Excel But fit <- lm(y~x, some data) plot(some vector, predict(fit, newdata=some vector)) or even plot(fit) will give you far better results then Excel can do. Regards Petr r-help-bounces at r-project.org napsal dne 23.07.2009 08:50:35:> > I just have a simple question. I'm using the predict function, and I get > about 1000 values. Now, how would I make it into a data frame or a listso> that I can easily use Excel to graph the data? Right now, it's inhorizontal> lines, and it would be a pain to copy and paste and make it into avertical> column. > Thanks! > -- > View this message in context:http://www.nabble.com/simple-question-about-> exporting-data...-tp24620281p24620281.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Doing the computations in R then the graphs in Excel reminds me of the maxim: Measure with a micrometer Mark with chalk Cut with an ax Before continuing you should really read: http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html and look at the final graphic in: http://www.cs.uiowa.edu/~jcryer/JSMTalk2001.pdf given that, I usually use predict like:> newdata$pred <- predict(fit1, newdata)Now the predicted values are a new column in the newdata data frame which can then be sent to excel (shudder) using write.table. Or better, just use this data frame to do the plots in R. You may also want to look at the Rexcel project that allows you to use R as a backend computation and graphics engine for an Excel front end. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Rbeginner > Sent: Thursday, July 23, 2009 12:51 AM > To: r-help at r-project.org > Subject: [R] simple question about exporting data... > > > I just have a simple question. I'm using the predict function, and I > get > about 1000 values. Now, how would I make it into a data frame or a list > so > that I can easily use Excel to graph the data? Right now, it's in > horizontal > lines, and it would be a pain to copy and paste and make it into a > vertical > column. > Thanks! > -- > View this message in context: http://www.nabble.com/simple-question- > about-exporting-data...-tp24620281p24620281.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.
On Jul 23, 2009, at 8:59 AM, Greg Snow wrote:> Doing the computations in R then the graphs in Excel reminds me of > the maxim: > > Measure with a micrometer > Mark with chalk > Cut with an axDefinitely a fortunes candidate... Marc Schwartz
I vote for it. --- On Thu, 7/23/09, Marc Schwartz <marc_schwartz at me.com> wrote:> From: Marc Schwartz <marc_schwartz at me.com> > On Jul 23, 2009, at 8:59 AM, Greg Snow wrote: > > > Doing the computations in R then the graphs in Excel > reminds me of the maxim: > > > > Measure with a micrometer > > Mark with chalk > > Cut with an ax> > Definitely a fortunes candidate... > > Marc Schwartz >__________________________________________________________________ [[elided Yahoo spam]]