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 - Ebean enhancement ignores a model -

ubuntu - How to disable Kernel Module Signing in linux -

SQL php on different pages to Insert (mysqli) -