[R] splitting character strings and converting to numeric vectors

2010-05-06 Thread Jim Bouldin
This seemingly should be quite simple but I can't solve it: I have a long character vector of geographic data (data frame column named XY) whose elements vary in length (from 11 to 14 chars). Each element is structured as a set of digits, then an underscore, then more digits, e.g:

Re: [R] splitting character strings and converting to numeric vectors

2010-05-06 Thread Gabor Grothendieck
Try this: x - c(-448623_854854, -448563_854850, -448442_854842, -448301_854833, + -448060_854818, -446828_854736) read.table(textConnection(x), sep = _) V1 V2 1 -448623 854854 2 -448563 854850 3 -448442 854842 4 -448301 854833 5 -448060 854818 6 -446828 854736 Here is another way.