[R] read.table with more than one sep

Jan.Schwanbeck at hydrologie.unibe.ch Jan.Schwanbeck at hydrologie.unibe.ch
Thu Apr 19 16:30:47 CEST 2007


Dear List,

somebody knows, if the following operation can be done in an easier way?

The data rows which should be read into R look like that:

4547;1970.01.01 00:00-1970.01.01 01:00;   noData

Unitil now we are doing this procedure:

1. Dividing columns which are separated by ";"

=>  temp <- read.table(file ,sep=';', na.strings='noData',
strip.white=TRUE)
=> write(temp, temp.txt)

2. Dividing colums which are separated by "-"

=>  temp <- read.table(temp.txt ,sep='-', na.strings='noData',
strip.white=TRUE)
=> write(temp, temp.txt)

3. Dividing colums which are separated by " "

=>  temp <- read.table(temp.txt ,sep=' ', na.strings='noData',
strip.white=TRUE)

I can imagine that there should be a way to do this more efficient.

Thanks for help in advance.

Jan Schwanbeck

University of Berne
Institute of Geography



More information about the R-help mailing list