I like to use split() to split your data into groups, then run
lapply() to use fitdistr on each element of the list.
E.g,
df <- data.frame(X = rnorm(500), ID = sample(letters[1:5], 500, TRUE))
temp <- split(df$X, df$ID)
lapply(temp, fitdistr, "normal")
Though it's just as easy with tapply():
t
Hi,
I have a variable X classified in a lot of groups and I need to run the
[fitdistr] funtion for each group. I tried with the [by] or the [tapply]
funtions because my data is organize in two columns (variable and the
groups), but neither of these command work. If somebody have a tip to help
me
2 matches
Mail list logo