Re: [R] Using the shape () function

From: hadley wickham <h.wickham_at_gmail.com>
Date: Tue, 17 Jun 2008 15:13:42 -0500

>> 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!)

Hadley

-- 
http://had.co.nz/

______________________________________________
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.
Received on Tue 17 Jun 2008 - 20:41:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 18 Jun 2008 - 06:30:49 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive