I’m doing intro to R, and i’m currently within the cleaning data section.
throughout the whole lesson code academy has been really good about explaining the syntax, but it seems like a ball was dropped here.
I don’t understand what the purpose of the two backslashes (\) are in the code below. What do they do and will I always need to add them? Are there times when gsub calls for one or three or more backslashes?
here’s the code from the example asking to get rid of the ‘$’ in the price, e.g. ‘$2.50’
fruit %>% mutate(price=gsub('\\$','',price))
and here’s the code from the problem asking to get rid of the ‘%’ in the scores, e.g. ‘60%’
students %>% mutate(score=gsub('\\%','',score))