search for: meanlight

Displaying 1 result from an estimated 1 matches for "meanlight".

Did you mean: enlight
2009 Feb 03
3
lapply and aggregate function
Dear list, I have two things I am struggling... # First set.seed(123) myD <- data.frame( Light = sample(LETTERS[1:2], 10, replace=T), Feed = sample(letters[1:5], 20, replace=T), value=rnorm(20) ) # Mean for Light myD$meanLight <- unlist( lapply( myD$Light, function(x) mean( myD$value[myD$Light == x]) ) ) # Mean for Feed myD$meanFeed <- unlist( lapply( myD$Feed, function(x) mean( myD$value[myD$Feed == x]) ) ) myD # I would like to get a new Var "meanLightFeed&...