I am having trouble getting the desired number of decimal places from summarise. Here is a simple example:
test2 <- data.frame(c(\"a\",\"a\",\"b\",\"b\")
I think the simplest solution is the following:
test2 <- data.frame(c("a","a","b","b"), c(245,246,247,248)) library(dplyr) colnames(test2) <- c("V1","V2") group_by(test2,V1) %>% summarise(`mean(V2)` = sprintf("%0.1f",mean(V2))) # A tibble: 2 x 2 V1 `mean(V2)` 1 a 245.5 2 b 247.5