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.n4.nabble.com/question-about-string-handling-tp2289178p2289327.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to