On Jun 12, 2008, at 6:34 PM, Hua Li wrote:
Thanks, Marc and Haris!
I didn't know the values of the numbers beforehand, so the scan
method won't work, but "[^+-\\d.]+" will do!
And Haris, I didn't intend to keep the information of which number
is B, which is C etc when asking the question, as I had a tedious
way to do it (use strspilt and unlist over and over again, after I
get the number). But if you have a easier way to do it, I'd like to
know!
Depending on how your real use case looks like, the following might
work:
vec1 <- strsplit(outtree.new, "[^+-\\d.:\\w]+", perl=TRUE)[[1]]
nums <- as.numeric(gsub("\\w?:","", vec1, perl=TRUE))
names(nums) <- gsub(":[+-\\d.]+","", vec1, perl=TRUE)
If it doesn't, then provide us with the example that fails it.
Hua
Haris Skiadas
Department of Mathematics and Computer Science
Hanover College
______________________________________________
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.