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,
%>%
gsub()
Try this:
library(stringr) df$D <- df$A %>% { gsub("\\.","", .) } %>% str_trim() %>% { as.numeric(gsub(",", ".", .)) }
With pipe your data are passed as a first argument to the next function, so if you want to use it somewhere else you need to wrap the next line in {} and use . as a data "marker".
{}
.