Skip to content

simple question about exporting data...

6 messages · Rbeginner, PIKAL Petr, Greg Snow +3 more

#
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!
#
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:
so
horizontal
vertical
http://www.nabble.com/simple-question-about-
http://www.R-project.org/posting-guide.html
#
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:
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.
#
On Jul 23, 2009, at 8:59 AM, Greg Snow wrote:

            
Definitely a fortunes candidate...

Marc Schwartz
#
I vote for it.
--- On Thu, 7/23/09, Marc Schwartz <marc_schwartz at me.com> wrote:

            
__________________________________________________________________
[[elided Yahoo spam]]
#
Marc Schwartz wrote:
This looks to me like a case of "If it doesn't look like all the other 
graphs that have been produced with Excel the boss won't accept it".

Jim