After you removed the extra ) at the end of the last line the code ran correctly and filtered_toothgrowth should be under the Environment tab in the upper-right pane.
The group="drop"
creates a new variable named group with values of drop. If you want to specify a grouping structure for the result, use .groups =
. For this example, it is not needed.
library(tidyverse)
ToothGrowth %>%
filter(dose == 0.5) %>%
group_by(supp) %>%
summarise(mean_len = mean(len, na.rm = TRUE), group = "drop")
#> # A tibble: 2 × 3
#> supp mean_len group
#> <fct> <dbl> <chr>
#> 1 OJ 13.2 drop
#> 2 VC 7.98 drop
ToothGrowth %>%
filter(dose == 0.5) %>%
group_by(supp) %>%
summarise(mean_len = mean(len, na.rm = TRUE), .groups = "drop")
#> # A tibble: 2 × 2
#> supp mean_len
#> <fct> <dbl>
#> 1 OJ 13.2
#> 2 VC 7.98
ToothGrowth %>%
filter(dose == 0.5) %>%
group_by(supp) %>%
summarise(mean_len = mean(len, na.rm = TRUE))
#> # A tibble: 2 × 2
#> supp mean_len
#> <fct> <dbl>
#> 1 OJ 13.2
#> 2 VC 7.98
Created on 2023-02-25 with reprex v2.0.2
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.