[R] Using the shape () function

Tom Backer Johnsen backer at psych.uib.no
Wed Jun 18 08:07:09 CEST 2008

hadley wickham wrote:
>>> You might try using the reshape package instead:
>>> last <- function(x) x[length(x)]
>>> names(d) <- c("value", "person", "time")
>>> cast(d, person ~ time, last)
>> The first and the last line I think is clear, although I will have to
>> experiment more to understand the call on cast () better.  However, what I
>> do not understand is the purpose of the second line.  I can print out
>> names(d) right after the reading the frame with the read.table function.  If
>> I print names (d) right after that statement has been executed, then I see
>> no difference.  Even so, it seems to be necessary for the call on cast to
>> work.  It seems that "names" is not the same as "names".  Something along
>> the lines of a with () or attach () perhaps?
> It's a small change - but cast requires the value column to be called
> "value" (no s!)

Aha!  Thank you!

> Hadley

More information about the R-help mailing list