0

i would like to know if it is possible to write a (character) name with e.g. paste in dplyr::summarise?

For example:

i <- "name"

# first working
iris %>%
  filter(Species == "setosa") %>%
  summarise(Sum_name = sum(Sepal.Length))

# second working
iris %>%
  filter(Species == "setosa") %>%
  summarise("Sum_name" = sum(Sepal.Length))

# third not working
iris %>%
  filter(Species == "setosa") %>%
  summarise(paste0("Sum_", i) = sum(Sepal.Length))

Is it possible to write something like the third example with paste?

Thank you in advance.

user5514978
  • 374
  • 5
  • 12

0 Answers0