Displaying 3 results from an estimated 3 matches for "chick_m".
Did you mean:
chick
2012 Apr 12
1
Using dcast with multiple functions to aggregate
...Please find attached
some example code using the ChickWeight data.
Many thanks for your help!
Jokel
#Chick weight example
names(ChickWeight) <- tolower(names(ChickWeight))
sd(ChickWeight$weight) # works fine
mean(ChickWeight$weight) # works fine
length(ChickWeight$weight) # works fine
chick_m <- melt(ChickWeight, id=2:4, na.rm=TRUE)
dcast(chick_m, time~variable, mean) # works fine
dcast(chick_m, time~variable, length) # works fine
dcast(chick_m, time~variable, fun.aggregate=sd) # gives an error
dcast(chick_m, time~variable, c(mean, length)) # gives an error
[[alternative HTML...
2008 Jul 30
1
bug in 'margins' behavior in reshape - cast
according to the documentation of the cast function in the reshape function,
I would expect this bit of code from the examples to calculate marginal
means over only the 'diet' variable.
#Chick weight example
names(ChickWeight) <- tolower(names(ChickWeight))
chick_m <- melt(ChickWeight, id=2:4, na.rm=TRUE)
cast(chick_m, diet + chick ~ time, mean, margins="diet")
But,
summary(cast(subset(chick_m, time == 0), diet + chick ~ time, mean,
margins="diet")) returns:
diet chick 0
1 :21 (all) : 4 Min. :39...
2009 Jul 06
2
ReShape chicks example - line plots
Hi,
In the examples from the ReShape package there is a simple example
of using melt followed by cast that produces a smallish amount of
output about the chicks database. Here's the code:
library(reshape)
names(ChickWeight) <- tolower(names(ChickWeight))
chick_m <- melt(ChickWeight, id=2:4, na.rm=TRUE)
DietResults <- cast(chick_m, diet + chick ~ time)
DietResults
My challenge is to extract an plot only a portion of this data.
I would like to plot the data for each chick that participated in
diet 1 only. Assume that the numbered column names (...