I'm wondering if someone can point out why this simple example doesn't work.
I think it's something to do with the fact that I'm using the !! operator?
But been unable to figure out what I'm doing wrong.
I want to get the number of rows from the starwars
dataset where the condition in x$value
is satisfied.
I run into the error Error in is_character(x) : object '.x' not found
.
library(dplyr)
library(purrr)
library(rlang)
x <- tibble(
value = c("skin_color == 'fair'")
)
x %>%
mutate(nrows = map_dbl(
value,
~ {
starwars %>%
filter(!!parse_expr(.x)) %>%
nrow()
}
))