[R] Errors in reading in txt files

lily li chocold12 at gmail.com
Thu Dec 14 19:36:46 CET 2017


Hi R users,

I have a question about reading from text files. The file has the structure
below:

Time                            Column1   Column2
01.01.2001-12:00:00
01.01.2001-24:00:00        12             11
01.02.2001-12:00:00        13             10
01.02.2001-24:00:00        11             12
01.03.2001-12:00:00        15             11
01.03.2001-24:00:00        16             10
...

I just use the simple script to open it: df = read.table('DATAM', head=T).

But it has the error and thus cannot read the file:
Error in scan(file = file, what = what, sep = sep, quote = quote, dec =
dec,  :
  line 1 did not have 3 elements

How to read it with three fixed columns, and how to read the time format in
the first column correctly? Thanks for your help.

	[[alternative HTML version deleted]]



More information about the R-help mailing list