MOst search results give me the reverse of this, turn NULL or NA into a string 'NA'. I don't want that, I want to turn string instances of 'NULL' into NA but am getting an error:
bla <- c('foo', 'bar', NA, 'NULL')
str_replace_all(bla, 'NULL', NA)
Error: `replacement` must be a character vector
Also tried:
str_replace_all(bla, 'NULL', NA_real_)
Error: `replacement` must be a character vector
How can I convert cases of 'NULL' into NA in bla?
[edit]
To be explicit, I'm actually doing this within a dplyr chain e.g.
bla <- data.frame(s = c('foo', 'bar', NA, 'NULL'), n = 1:4 )
> bla
s n
1 foo 1
2 bar 2
3 <NA> 3
4 NULL 4
> bla %>% mutate(s = str_replace_all(bla, 'NULL', NA_real_))
Error: Problem with `mutate()` input `s`.
x `replacement` must be a character vector
ℹ Input `s` is `str_replace_all(bla, "NULL", NA_real_)`.