Can my R code work?

Screen Link:
https://app.dataquest.io/m/324/string-manipulation-and-relational-data/6/subsetting-strings

My Code:

hs_directory<- hs_directory%>% mutate(lat=str_sub(lat,2,-1), long=str_sub(long,1,-2))
hs_directory<- hs_directory%>% mutate_at(vars(lat,long), as.numeric)

What I expected to happen:
There could be a bug, but I would like to know if my code would work! Thanks!

What actually happened:

Replace this line with the output/error

Hello @lauratangwt Your code is Ok.

Also something to note, since hs_directory is the input in the second line you could use the second line piped with the first one

hs_directory<- hs_directory %>% 
    mutate(lat=str_sub(lat,2,-1), long=str_sub(long,1,-2)) %>% 
    mutate_at(vars(lat,long), as.numeric)
1 Like