regex help splitting string on the hyphen and space characters in R -
i have string follows:
"ipf-plasma 1"
i'd split on "-" , "\\s". tried following:
strsplit(cleandata[[1]][1,1], "-|s")
however, gives,
> strsplit(cleandata[[1]][1,1], "-|s") [[1]] [1] "ipf" "pla" "ma 1"
why there split on "plasma"? , how fix it?
you had it... forgot slashes...
a <- "ipf-plasma 1" > strsplit(a, "-|s") [[1]] [1] "ipf" "pla" "ma 1" > strsplit(a, "-|\\s") [[1]] [1] "ipf" "plasma" "1"
Comments
Post a Comment