Hi @Elle,
It is great that you solved your challenge, but I still think that in order to get a full learning experience, you should make sure, that you understand the difference between NULL and "NULL". The first represents the null object in R and the latter is a string/character. This is what I was hinting at in my first post:
is.null("NULL")
# [1] FALSE
is.null(NULL)
# [1] TRUE
is.character("NULL")
# [1] TRUE
is.character(NULL)
# [1] FALSE
So given the vector
v = c("NULL", "1", "9", "NULL")
What you are doing is not looking for NULL values, but looking for specific strings, when you do
v[v == "NULL"]
Furthermore, you have the remaining values "1" and "9" as strings, so what you want to do is the following:
# Load libraries
library("tidyverse")
# Define dummy tibble
d = tibble(v = c("NULL", "1", "9", "NULL"))
# View dummy tibble
# note the <chr>, which tells you that v is a character
d
# A tibble: 4 x 1
v
<chr>
1 NULL
2 1
3 9
4 NULL
# Replace "NULL" with NA and convert to numeric
# note the <dbl> which tells you that v is now a numeric
# (Skipping `numeric` vs. `double` vs. `integer` for now)
d %>% mutate(v = ifelse(v == "NULL", NA, v) %>% as.numeric)
# A tibble: 4 x 1
v
<dbl>
1 NA
2 1.
3 9.
4 NA
Hope it helps and I really would highly recommend, that you go through R for Data Science to get a better understanding of the above concepts in R
