Probably the solution is simple, but I can't find it right now. I like to use tapply in descriptive-statistical analyses. For example:
tapply(dataframe1$Means, dataframe2$gender, function(x) {
c(
"mean" = mean(x, na.rm = TRUE),
"sd" = sd(x, na.rm = TRUE),
"med" = median(x, na.rm = TRUE),
"min" = min(x, na.rm = TRUE),
"max" = max(x, na.rm = TRUE)
)
})
Now I would like to have the results rounded directly to two places, but without writing them to another or new object.
Thanks for tips
Is it what you are looking for? I added
round(c(...), digits = 2)around the group of summary functions (mean, sd, etc.) so the function does the rounding insidetapplywithout creating a new object.Edit: better version without repeating the
round()function.Created on 2022-05-10 by the reprex package (v2.0.1)