[R] two questions about character manipulation

Rui Barradas ruipbarradas at sapo.pt
Sun Sep 16 19:44:01 CEST 2012


Hello,

This should do it. You can collapse the first two instructions, but I've 
left it like this for clarity.

s <- unlist(strsplit(ex, "[,)[:blank:]]"))
s <- gsub("^.*\\$", "", s)
s[nchar(s) > 0]

Rui Barradas

Em 16-09-2012 17:26, Özgür Asar escreveu:
> Dear Rui Barradas and Michael Weylandt,
>
> Many thanks for your replies.
>
> My second question is solved now.
>
> But I think I did not expressed my first wish in a clear way
>
> Indeed,
>
> in ex<-"cbind(data$response1,data$response2),
>
> I want to extract the variable name between "$" and "," (corresponds to
> response1 in this example) and the one between "$" and ")" (corresponds to
> response2).
>
> These symbols ("$", ",", ")" ) are always same, but the names (response1,
> response2) might change from data to data.
>
> Best
>
> Ozgur
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/two-questions-about-character-manipulation-tp4643292p4643301.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.




More information about the R-help mailing list