Dear all, I'd like to get a percentage variable based on a group, but without
creating a new data frame.
For example:
data(iris)
iris$percent <-unlist(tapply(iris$Sepal.Length,iris$Species,function(x)
x/sum(x, na.rm=TRUE)))
This does not work, I should have only three standard values, respectively for
setosa, versicolor, and virginica. How can I do this?
MANY THANKS,
Karine
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.