Hi all,
It's a while since I needed this behaviour, but cast now seems do
things differently from what was documented in the JSS introductory
article.
Specifically, using the french_fries data set:
library(reshape)
# check no observations at time 10 for subject 3:
subset(french_fries, subject ==3 & time==10)
ff_d <- melt(french_fries, id=1:4, na.rm=TRUE)
cast(ff_d, subject ~ time, length) # generates "0" instead of NAs
shown at top of p.17
# BTW, above output not generated by command at bottom of p. 16
# but I guess you already knew that
cast(ff_d, subject ~ time, length, fill=0) # supposed to replace NAs
with zeroes?
cast(ff_d, subject ~ time, function(x) 30 - length(x)) # now get "30"
instead of NA
cast(ff_d, subject ~ time, function(x) 30 - length(x), fill=30) #
supposed to replace NAs with "30"?
I'm pretty sure that originally (i.e. a few versions of R ago) cast()
did what it says on p. 17 of the JSS article, i.e. generate NAs where
there were "missing cells", and the "fill" argument could be used to
substitute a value for these NAs.
Has something changed in the meantime? Is there a way to get cast() to
behave in the way it did originally?
Cheers,
Leon
--
You received this message because you are subscribed to the Google Groups "manipulatr" group.
To post to this group, send email to manip...@googlegroups.com.
To unsubscribe from this group, send email to manipulatr+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/manipulatr?hl=en.
Yes, this is the reasoning behind the new(er) behaviour. Instead of
filling with NAs by default, I fill with the results of calling the
function on a zero-length vector.
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/