[R] looking for one-liner for strsplit and regex
    Juliet Hannah 
    juliet.hannah at gmail.com
       
    Sun Apr 12 02:23:15 CEST 2009
    
    
  
Hi,
I have a line such as:
myline <-  "    0.100000      1.5000      0.6000                 538
 0.369404"
and I would like to put the numbers into a vector. Some combination of
tabs and spaces occur between the numbers.
I tried:
try1 <- strsplit(myline,"[[:blank:]]+")
> try1
[[1]]
[1] ""         "0.100000" "1.5000"   "0.6000"   "538"      "0.369404"
The first element is "", which I do not want. I can get rid of the
"", but I was wondering if someone can show me the proper way to do
this in 1 line.
Thanks,
Juliet
    
    
More information about the R-help
mailing list