Hello all,
I'm looking for a way to be able to read a text file into R. It's a csv
file but when I do
"txt <-read.table("F00.csv", header=T,
sep=",")" It doesn't read the
file properly, and I only get 2 columns. If I open it up in OOc or Excel
it open right with 7 columns.
What I would really like to do is read the file as text and then split
it and read the bottom section where the 7 columns are. Then I would
re-read the table with read.table.
Thank you for any help,
Paul
--
Research Technician
Mass Spectrometry
o The
/
o Scripps
\
o Research
/
o Institute
On 17-Feb-07 H. Paul Benton wrote:> Hello all, > > I'm looking for a way to be able to read a text file into R. > It's a csv file but when I do > "txt <-read.table("F00.csv", header=T, sep=",")" > It doesn't read the file properly, and I only get 2 columns. > If I open it up in OOc or Excel it open right with 7 columns. > What I would really like to do is read the file as text and > then split it and read the bottom section where the 7 columns are. > Then I would re-read the table with read.table. > > Thank you for any help, > > PaulWhat's wrong with using read.csv? (Or have I misunderstood your query?) Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <ted.harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 17-Feb-07 Time: 00:39:37 ------------------------------ XFMail ------------------------------
'count.fields' is often useful in such situations to see how R's view of the file differs from your own. (It isn't such a rare occurrence for differences to happen when the file comes from Excel.) If I understand properly, you can use sep='\n' as part of your alternative plan. But I don't think you would need to write a file and read it back in again. Patrick Burns patrick at burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User") H. Paul Benton wrote:>Hello all, > >I'm looking for a way to be able to read a text file into R. It's a csv >file but when I do >"txt <-read.table("F00.csv", header=T, sep=",")" It doesn't read the >file properly, and I only get 2 columns. If I open it up in OOc or Excel >it open right with 7 columns. >What I would really like to do is read the file as text and then split >it and read the bottom section where the 7 columns are. Then I would >re-read the table with read.table. > > Thank you for any help, > > Paul > > >