Hi, I'm looking for some way to pick up the numbers which are contained and buried in a long character.
For example, outtree.new="(((B:1204.25,E:1204.25):7581.11,F:8785.36):8353.85,C:17139.21);" num.char = unlist(strsplit(unlist(strsplit(unlist(strsplit(unlist(strsplit(unlist(strsplit(outtree.new,")",fixed=TRUE)),"(",fixed=TRUE)),":",fixed=TRUE)),",",fixed=TRUE)),";",fixed=TRUE)) num.vec=as.numeric(num.char[1:(length(num.char)-1)]) num.char # "B" "1204.25" "E" "1204.25" "7581.11" "F" "8785.36" "8353.85" "C" "17139.21" "" num.vec # NA 1204.25 NA 1204.25 7581.11 NA 8785.36 8353.85 NA 17139.21 would help me get the numbers such as 1204.25, 7581.11, etc, but with a warning message which reads: "Warning message: NAs introduced by coercion " Is there a way to get around this? Thanks! Hua ______________________________________________ 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.