I have the following data frame:
library(tidyverse)
iris %>%
dplyr::select(Species, Petal.Width) %>%
as_tibble()
Then I group by Species to get mean_se with the following line of code:
df <- iris %>%
dplyr::select(Species, Petal.Width) %>%
as_tibble() %>%
group_by(Species) %>%
mutate(ms = mean_se(Petal.Width))
It looks like this:
df
# A tibble: 150 x 3
# Groups: Species [3]
Species Petal.Width ms$y $ymin $ymax
<fct> <dbl> <dbl> <dbl> <dbl>
1 setosa 0.2 0.246 0.231 0.261
2 setosa 0.2 0.246 0.231 0.261
3 setosa 0.2 0.246 0.231 0.261
4 setosa 0.2 0.246 0.231 0.261
5 setosa 0.2 0.246 0.231 0.261
6 setosa 0.4 0.246 0.231 0.261
7 setosa 0.3 0.246 0.231 0.261
8 setosa 0.2 0.246 0.231 0.261
9 setosa 0.2 0.246 0.231 0.261
10 setosa 0.1 0.246 0.231 0.261
However when I want to select ms$y and $ymax column, like this
> df %>% dplyr::select(Species, ms$y, $ymax)
Error: unexpected '$' in "df %>% dplyr::select(Species, ms$y, $"
It fails. What's the way to do it?