Hello there,
I am sort of running in circle with a trouble as I know there is a better way than my current moethod but can't seem to figure it out. I'd like to figure out the "percentage of a maximum value within a group". Using the iris dataset here is what I am currently doing:
library(plyr)
iris1<-merge(
ddply(iris, .(Species), summarize,
maxPetal.Width=max(Petal.Width)
),
iris, by=c("Species")
)
iris1$PerMax<-round(iris1$Petal.Width/iris1$maxPetal.Width, 2)
iris1
However, this seems cumbersome and I feel like there is a way to do this all while one instance of ddply. Can anyone recommend a better way of getting at this?