Paul Rigor (ucla)
2010-Apr-19 10:13 UTC
[R] Formatting data, adding column names, use reshape, a newbie question
Hi all, I'm an R novice. I have data that's already formatted as "molten" that reshape should be able to work with. For example, the following was read in with read.csv(filename,sep=" ", header=FALSE) V1 V2 V3 V4 V5 1 original book book.source1.txt 328900494 3039.525 2 original book book.source1.txt 328900494 3057.952 I would like add column names so I can use reshape's cast method. How do I go about that? Thanks, Paul [[alternative HTML version deleted]]
hadley wickham
2010-Apr-19 15:15 UTC
[R] Formatting data, adding column names, use reshape, a newbie question
On Mon, Apr 19, 2010 at 5:13 AM, Paul Rigor (ucla) <pryce at ucla.edu> wrote:> Hi all, > I'm an R novice. > > I have data that's already formatted as "molten" that reshape should be able > to work with. For example, the following was read in with > read.csv(filename,sep=" ", header=FALSE) > > ? ? ?V1 ? ? ? ? ? ? ? V2 ? ? ? ? V3 ? ? ? ? ? ? ? ? V4 > ?V5 > 1 ? ?original ? ?book ? ?book.source1.txt ? ?328900494 ? ?3039.525 > 2 ? ?original ? ?book ? ?book.source1.txt ? ?328900494 ? ?3057.952 > > > I would like add column names so I can use reshape's cast method.names(df) <- c("col1", "col2", ..., "col5") ? Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/