[R] readLines: how to make a data.frame?

johannes rara johannesraja at gmail.com
Tue Oct 19 13:27:32 CEST 2010


I have a text file containing data:

Som text
::
asdf
@  1  ds  $  5. /*Edmp  */
@  8  asu  $  3. /*daf*/
@  8  asdala  $  2. /*asdfa*/
@  13  astun  $  11. /*daf */
@  26  dft  $  3. /*asdf */
@  31  dsfp  $  2. /*asdf  */
asjk
asdfö

My intention is to create a dataframe from this data (only rows
starting @ and not containng string "asdf"). I tried to read this data
using this code:

g <- readLines("temp.txt")
g <- grep("^@", g, value=T)
g <- gsub("[@|$|\\.|/*]", "", g)

How to put this data into a data.frame?

-J



More information about the R-help mailing list