Dirty D
2008-Nov-08 04:23 UTC
[R] New to List - just starting to learn R - question about reading in data
Hi, everyone, I'm new to R and the List, and excited to be here. I am coming from a background working in SPSS 16, primarily, which has a lot of easy options for reading in data. I am working in R in an Ubuntu Linux environment, and I'm learning with R Commander. Now, here's my question. In my line of work, I'm used to getting data in some kind of flat ASCII format with a separate file indicating which columns correspond to which variables. In the Venables and Ripley book on S/R that I'm reading, there doesn't seem to be a way to read this kind of data format into R, and I haven't found anything online. If anyone has the tine, I'd sure appreciate a little guidance. Thanks, DD
Erik Iverson
2008-Nov-08 04:38 UTC
[R] New to List - just starting to learn R - question about reading in data
Welcome! Dirty D wrote:> Hi, everyone, > > I'm new to R and the List, and excited to be here. I am coming from a > background working in SPSS 16, primarily, which has a lot of easy > options for reading in data. I am working in R in an Ubuntu Linux > environment, and I'm learning with R Commander.I work with R in Ubuntu also, it is a good decision I think. I use ESS (a package for Emacs), however.> > Now, here's my question. In my line of work, I'm used to getting data in > some kind of flat ASCII format with a separate file indicating which > columns correspond to which variables. In the Venables and Ripley book > on S/R that I'm reading, there doesn't seem to be a way to read this > kind of data format into R, and I haven't found anything online.Certainly, look up read.table (?read.table in R) and in V&R, bottom of page 21 specifically. There is also an R Data Import/Export manual on the project's site. But, read.table is almost surely what you're looking for. test <- read.table("/path/to/file", header = TRUE) This is a common example if your text file has a first row of variable names. See pages 21-22 for more examples. HTH!> > If anyone has the tine, I'd sure appreciate a little guidance. > Thanks, > > DD > > ______________________________________________ > 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.
cryan at binghamton.edu
2008-Nov-08 04:46 UTC
[R] New to List - just starting to learn R - question about reading in data
I've not had occasion to use it yet, but perhaps read.fwf. At the R command prompt, type ?read.fwf to learn about it. --Chris Ryan ---- Original message ---->Date: Fri, 07 Nov 2008 23:23:18 -0500 >From: Dirty D <dirtyd at overdetermined.net> >Subject: [R] New to List - just starting to learn R - question about reading in data >To: r-help at r-project.org > >Hi, everyone, > >I'm new to R and the List, and excited to be here. I am coming from a >background working in SPSS 16, primarily, which has a lot of easy >options for reading in data. I am working in R in an Ubuntu Linux >environment, and I'm learning with R Commander. > >Now, here's my question. In my line of work, I'm used to getting data in >some kind of flat ASCII format with a separate file indicating which >columns correspond to which variables. In the Venables and Ripley book >on S/R that I'm reading, there doesn't seem to be a way to read this >kind of data format into R, and I haven't found anything online. > >If anyone has the tine, I'd sure appreciate a little guidance. > >Thanks, > >DD > >______________________________________________ >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.
Prof Brian Ripley
2008-Nov-08 07:05 UTC
[R] New to List - just starting to learn R - question about reading in data
Are you looking for read.fwf? I've not seen that form of data file since the days of punched cards. (That _was_ the era when SPSS was written._) (Real names and real signature blocks are preferred here.) On Fri, 7 Nov 2008, someone wrote:> Hi, everyone, > > I'm new to R and the List, and excited to be here. I am coming from a > background working in SPSS 16, primarily, which has a lot of easy options for > reading in data. I am working in R in an Ubuntu Linux environment, and I'm > learning with R Commander. > > Now, here's my question. In my line of work, I'm used to getting data in some > kind of flat ASCII format with a separate file indicating which columns > correspond to which variables. In the Venables and Ripley book on S/R that > I'm reading, there doesn't seem to be a way to read this kind of data format > into R, and I haven't found anything online. > > If anyone has the tine, I'd sure appreciate a little guidance. > Thanks, > > DD > > ______________________________________________ > 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. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595