Re: [R] Errors in reading in txt files

2017-12-15 Thread Jeff Newmiller
Your times are formatted as 01.01.2001-24:00:00 but the default format is 2001-01-01 24:00:00 so you need to specify a format argument with as.POSIXct. Read about format strings in ?strptime. -- Sent from my phone. Please excuse my brevity. On December 15, 2017 9:21:54 AM PST, lily li wrote

Re: [R] Errors in reading in txt files

2017-12-15 Thread David Winsemius
> On Dec 15, 2017, at 9:21 AM, lily li wrote: > > I use the method, df$Time = as.POSIXct(df$Time), but it has the warning > message: > Error in as.POSIXlt.character(x, tz, ...) : > character string is not in a standard unambiguous format That's because your date-time data is not in "%Y-%m-%d %

Re: [R] Errors in reading in txt files

2017-12-15 Thread lily li
I use the method, df$Time = as.POSIXct(df$Time), but it has the warning message: Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format On Thu, Dec 14, 2017 at 1:31 PM, MacQueen, Don wrote: > In addition to which, I would recommend > > df <- read.t

Re: [R] Errors in reading in txt files

2017-12-14 Thread MacQueen, Don
In addition to which, I would recommend df <- read.table("DATAM", header = TRUE, fill = TRUE, stringsAsFactors=FALSE) and then converting the Time column to POSIXct date-time values using as.POSIXct() specifying the format using formatting codes found in ?strptime because the times are not in

Re: [R] Errors in reading in txt files

2017-12-14 Thread Berend Hasselman
> On 14 Dec 2017, at 20:01, Ista Zahn wrote: > > On Thu, Dec 14, 2017 at 1:58 PM, Berend Hasselman wrote: >> >>> On 14 Dec 2017, at 19:36, lily li wrote: >>> >>> Hi R users, >>> >>> I have a question about reading from text files. The file has the structure >>> below: >>> >>> Time

Re: [R] Errors in reading in txt files

2017-12-14 Thread Ista Zahn
On Thu, Dec 14, 2017 at 1:58 PM, Berend Hasselman wrote: > >> On 14 Dec 2017, at 19:36, lily li wrote: >> >> Hi R users, >> >> I have a question about reading from text files. The file has the structure >> below: >> >> TimeColumn1 Column2 >> 01.01.2001-12:00:00 > > T

Re: [R] Errors in reading in txt files

2017-12-14 Thread lily li
Thanks, Berend. I thought R can recognize the space automatically, such as na.strings="", or sep=' '. On Thu, Dec 14, 2017 at 11:58 AM, Berend Hasselman wrote: > > > On 14 Dec 2017, at 19:36, lily li wrote: > > > > Hi R users, > > > > I have a question about reading from text files. The file ha

Re: [R] Errors in reading in txt files

2017-12-14 Thread Berend Hasselman
> On 14 Dec 2017, at 19:36, lily li wrote: > > Hi R users, > > I have a question about reading from text files. The file has the structure > below: > > TimeColumn1 Column2 > 01.01.2001-12:00:00 This line does not contain 3 elements; only one. You'll have to fix t

[R] Errors in reading in txt files

2017-12-14 Thread lily li
Hi R users, I have a question about reading from text files. The file has the structure below: TimeColumn1 Column2 01.01.2001-12:00:00 01.01.2001-24:00:0012 11 01.02.2001-12:00:0013 10 01.02.2001-24:00:0011