A simple question - I have a small dataset to read in and want to copy and paste part from Excel and paste it into an R script file without creating more files saving it as a .txt/.csv and then reading that in. I want to read in 3 columns e.g. 1 2.5 3.4 1 2.3 3.1 1 2.6 3.9 2 2.9 2.8 2 2.6 2.9 2 2.7 2.9 3 2.3 3.3 3 2.4 3.0 3 2.7 3.2 I thought I could use scan() but don't know how to extend it to multiple columns? I thought about using colwise (plyr) but think I am making this more complicated than it probably should be! Is there an easy way to do this? Any ideas gratefully received, Paul -- View this message in context: http://r.789695.n4.nabble.com/Read-in-dataset-without-saving-it-tp2248495p2248495.html Sent from the R help mailing list archive at Nabble.com.
See ?textConnection, eg test <-"1 2.5 3.4 1 2.3 3.1 1 2.6 3.9 2 2.9 2.8 2 2.6 2.9 2 2.7 2.9 3 2.3 3.3 3 2.4 3.0 3 2.7 3.2" x <- textConnection(test) read.table(x) close(x) On Wed, Jun 9, 2010 at 10:38 AM, Paul Chatfield <p.s.chatfield at reading.ac.uk> wrote:> > A simple question - I have a small dataset to read in and want to copy and > paste part from Excel and paste it into an R script file without creating > more files saving it as a .txt/.csv and then reading that in. ?I want to > read in 3 columns e.g. > 1 2.5 3.4 > 1 2.3 3.1 > 1 2.6 3.9 > 2 2.9 2.8 > 2 2.6 2.9 > 2 2.7 2.9 > 3 2.3 3.3 > 3 2.4 3.0 > 3 2.7 3.2 > > I thought I could use scan() but don't know how to extend it to multiple > columns? ?I thought about using colwise (plyr) but think I am making this > more complicated than it probably should be! ?Is there an easy way to do > this? > > Any ideas gratefully received, > > Paul > -- > View this message in context: http://r.789695.n4.nabble.com/Read-in-dataset-without-saving-it-tp2248495p2248495.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. >-- Joris Meys Statistical consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control tel : +32 9 264 59 87 Joris.Meys at Ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
See: http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows&s=excel On Wed, Jun 9, 2010 at 4:38 AM, Paul Chatfield <p.s.chatfield at reading.ac.uk> wrote:> > A simple question - I have a small dataset to read in and want to copy and > paste part from Excel and paste it into an R script file without creating > more files saving it as a .txt/.csv and then reading that in. ?I want to > read in 3 columns e.g. > 1 2.5 3.4 > 1 2.3 3.1 > 1 2.6 3.9 > 2 2.9 2.8 > 2 2.6 2.9 > 2 2.7 2.9 > 3 2.3 3.3 > 3 2.4 3.0 > 3 2.7 3.2 > > I thought I could use scan() but don't know how to extend it to multiple > columns? ?I thought about using colwise (plyr) but think I am making this > more complicated than it probably should be! ?Is there an easy way to do > this? > > Any ideas gratefully received, > > Paul > -- > View this message in context: http://r.789695.n4.nabble.com/Read-in-dataset-without-saving-it-tp2248495p2248495.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. >