Re: [R] question about string handling....

2010-07-16 Thread karena
hey, guys, all these methods work perfectly. thank you!! -- View this message in context: http://r.789695.n4.nabble.com/question-about-string-handling-tp2289178p2291497.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.

Re: [R] question about string handling....

2010-07-14 Thread Henrique Dallazuanna
Another option could be: df$var3 <- gsub(".*\\((.*)\\).*", "\\1", df$var2) On Wed, Jul 14, 2010 at 3:21 PM, karena wrote: > > Hi, > > I have a data.frame as following: > var1 var2 > 1 ab_c_(ok) > 2 okf789(db)_c > 3 jojfiod(90).gt > 4 "ij"_(78)__op

Re: [R] question about string handling....

2010-07-14 Thread Wu Gong
Try this: text <- 'var1 var2 1 ab_c_(ok) 2 okf789(db)_c 3 jojfiod(90).gt 4 "ij"_(78)__op 5 (iojfodjfo)_ab' df <- read.table(textConnection(text), head=T, sep=" ",quote="") df$var3 <- gsub("(.*\\()(.*)(\\).*)","\\2",df$var2) - A R learner. -- View this message in context: http://r.789695.

Re: [R] question about string handling....

2010-07-14 Thread Gabor Grothendieck
On Wed, Jul 14, 2010 at 2:21 PM, karena wrote: > > Hi, > > I have a data.frame as following: > var1         var2 > 1           ab_c_(ok) > 2           okf789(db)_c > 3           jojfiod(90).gt > 4           "ij"_(78)__op > 5           (iojfodjfo)_ab > > what I want is to create a new variable call

[R] question about string handling....

2010-07-14 Thread karena
Hi, I have a data.frame as following: var1 var2 1 ab_c_(ok) 2 okf789(db)_c 3 jojfiod(90).gt 4 "ij"_(78)__op 5 (iojfodjfo)_ab what I want is to create a new variable called "var3". the value of var3 is the content in the Parentheses. so v