string - Remove part of variable name for all variables in R -


i have dataset in of variable names begin string prior "." batch remove whole dataset.for example:

frame <- data.frame("sec.xx" = rnorm(10), "sec2.zz" = rnorm(10), "sec3.yy" = rnorm(10)) names(frame) 

i remove in of names prior "." such resulting variable names "xx", "zz", "yy". , thoughts.

you use sub function.

> names(frame) <- sub(".*\\.", "", names(frame)) > names(frame) [1] "xx" "zz" "yy" 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -