[R] manipulating strings
Gabor Grothendieck
ggrothendieck at myway.com
Sun Aug 8 22:03:41 CEST 2004
Stephen Nyangoma <S.Nyangoma <at> cs.rug.nl> writes:
:
: Hi
: I have a called fil consisting of the following strings.
:
: > fil
: [1] " 102.2 639" " 104.2 224" " 105.1 1159" " 107.1 1148"
: " 108.1 1376"
: [6] " 109.2 1092" " 111.2 1238" " 112.2 349" " 113.1 1204"
: " 114.1 537"
: [11] " 115.0 303" " 116.1 490" " 117.2 202" " 118.1 1864"
: " 119.0 357"
:
: I want to get a data frame like
:
: Time Obs
: 102.2 639
: 104.2 224
: 105.1 1159
: 107.1 1148
: 108.1 1376
: 109.2 1092
: 111.2 1238
: 112.2 349
: 113.1 1204
: 114.1 537
: etc
:
: Can anyone see an efficient way of doing this?
textConnection can be used to allow read.table to read them
as if it were reading from a file:
read.table(textConnection(fil), col.names = c("Time", "Obs"))
More information about the R-help
mailing list