Mmm, just Friday ... :)
Thank you jim gabor
-Messaggio originale-
Da: jim holtman
[mailto:jholt...@gmail.com]
Inviato: venerdì 2 ottobre 2009
14.12
A: Luca Braglia
Cc: r-help@r-project.org
Oggetto: Re: [R] help with
regexp mass substitution
You need perl=TRUE
Hello *
i have to rename a lot of variables, and, given that they have regular name
constructs, I would like to use regexps.
Here's a dump of my head(names(df))
varnames - c(id.quest, txt.1.3, col1.1.3, col2.1.3, col3.1.3,
col4.1.3, col5.1.3, txt.2.3, col1.2.3, col2.2.3, col3.2.3,
col4.2.3,
You need perl=TRUE:
gsub(^col(\\d{1,2}).(\\d{1,2}).(\\d{1,2}), dom\\3.rig\\2.col\\1,
varnames, perl=TRUE)
[1] id.questtxt.1.3 dom3.rig1.col1
dom3.rig1.col2 dom3.rig1.col3 dom3.rig1.col4 dom3.rig1.col5
[8] txt.2.3 dom3.rig2.col1 dom3.rig2.col2
dom3.rig2.col3
dot (.) matches anything so be sure to escape it so that it only
matches a literal dot in your regular expression.
On Fri, Oct 2, 2009 at 5:39 AM, Luca Braglia brag...@poleis.eu wrote:
Hello *
i have to rename a lot of variables, and, given that they have regular name
constructs, I would
4 matches
Mail list logo