[R] Regular Expressions Help

From: maud <maud.july_at_gmail.com>
Date: Fri, 18 Apr 2008 21:46:13 -0700 (PDT)

I am having some trouble learning regular expressions. Let me describe the general problem I am dealing with. Consider the following setup:

Joe<- c(1,2,3)
Bob<- c(2,4,6)
Alice <- c(9,8,7)

Matrix <- cbind(Joe, Bob, Alice)
St <- c("Bob", "Alice", "Alice:Bob")

Now I want to make a new matrix having only the column's listed in St that were in Matrix (which I can do). However, In addition for elements of the form "Alice:Bob" I want to make a new column in my new matrix with the product of these columns. I am not sure if a semicolon is a valid symbol for a column name, if not we can replace it with something like qqq.

I have been reading over various post on regular expressions, but really haven't made any progress. As far as I can tell there aren't standard string functions in R. (Also, as an aside, is there a wildcard character in R? I'd want something so if x="Bob" a statment of the form x== "B*b" would evaluate true where * is the wildcard.)

 Any help would be appreciated!

(also, thanks again to those who helped on my last question!)

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. Received on Sat 19 Apr 2008 - 07:58:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 19 Apr 2008 - 13:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive