[R] csv file with two header rows

peter dalgaard pdalgd at gmail.com
Sat Apr 27 09:48:22 CEST 2013


On Apr 26, 2013, at 14:48 , John Kane wrote:

> I don't think so. read.csv is a striped down version of read.table.  You should be able to do this with the skip option there.

You can also pass skip= to read.csv, it just passes it on to read.table. But it is not clear to me what is supposed to happen with the the double header, or what the file format in question is exactly. 

It is, e.g., quite possible to do something like

hd <- read.csv(..., nrows=2)
df <- read.csv(..., skip=2, header=FALSE)
names(df) <- ... some operation on hd ...

> 
> John Kane
> Kingston ON Canada
> 
> 
>> -----Original Message-----
>> From: analyst41 at hotmail.com
>> Sent: Thu, 25 Apr 2013 18:35:42 -0700 (PDT)
>> To: r-help at r-project.org
>> Subject: [R] csv file with two header rows
>> 
>> Is there a way to use read.csv() on such a file without deleting one
>> of the header rows?
>> 
>> Thanks.
>> 
>> ______________________________________________
>> 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.
> 
> ____________________________________________________________
> GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at http://www.inbox.com/smileys
> Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and most webmails
> 
> ______________________________________________
> 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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list