I'm new to R and RStudio and I'm trying to learn how to use tools from the tidyverse package for the purposes of data analysis.
I'm currently using the mutate() function but am having trouble understanding why the symbol ~ is necessary to make the following code work?
mutate(Amphitrite_temps_clean, across(where(is.character), ~na_if(., "999.99")))
For some reason if I just remove the the '~' symbol (which I've learned is called a tilde) in front of the ~na_if function, the code stops working. It gives me the following error:
Error in mutate(Amphitrite_temps_clean, across(where(is.character), na_if(., :
Caused by error in
vec_cast()
: object '.' not found
Would someone be able to help explain to me what the tilde symbol does in this context? I've been struggling with finding answers online. Sorry for the naivety guys!
I've tried to search and see why the tilde function does but many of the answers seem to be referring to other uses of the ~ symbol in R; not necessarily in the context of dplyr - tidy verse.