To clean some messy data I would like to start using pipes %>%
, but I fail to get the R code working if gsub()
is not at the beginning of the pipe,
The problem is that the argument that is fed into the pipe needs to be the first in the list of arguments. But this is not the case for gsub()
, as x
is the third one. A (wordy) workaround could be:
df$A %>%
gsub(pattern = "\\.", replacement="") %>%
str_trim() %>%
gsub(patter = ",", replacement = ".") %>%
as.numeric