[R] Locating data source error in large file
William Dunlap
wdun|@p @end|ng |rom t|bco@com
Fri Jul 20 22:44:21 CEST 2018
> And each dataframe row has this format:
>2015-10-01,00:00,90.6689
>2015-10-01,01:00,90.6506
>2015-10-01,02:00,90.6719
>2015-10-01,03:00,90.6506
You mean each line in the file, not row in data.frame, has the form
"year-month-day,hour:min,numericValue". Try the following, where tfile
names your file:
> df <- read.table(tfile, header=FALSE, sep=",", col.names=c("dateString",
"timeString", "Value"))
> df
dateString timeString Value
1 2015-10-01 00:00 90.6689
2 2015-10-01 01:00 90.6506
3 2015-10-01 02:00 90.6719
4 2015-10-01 03:00 90.6506
> transform(df, DateTime = as.POSIXlt(paste(dateString, timeString),
format="%Y-%m-%d %H:%M"), dateString=NULL, timeString=NULL)
Value DateTime
1 90.6689 2015-10-01 00:00:00
2 90.6506 2015-10-01 01:00:00
3 90.6719 2015-10-01 02:00:00
4 90.6506 2015-10-01 03:00:00
> str(.Last.value)
'data.frame': 4 obs. of 2 variables:
$ Value : num 90.7 90.7 90.7 90.7
$ DateTime: POSIXct, format: "2015-10-01 00:00:00" "2015-10-01 01:00:00"
"2015-10-01 02:00:00" "2015-10-01 03:00:00"
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Jul 20, 2018 at 1:24 PM, Rich Shepard <rshepard using appl-ecosys.com>
wrote:
> On Fri, 20 Jul 2018, William Dunlap wrote:
>
> Which format did you use when you used is.na on the output of
>> as.POSIXlt(strings, format=someFormat)
>> and found none? Did the resulting dates look OK? Perhaps
>> all is well.
>>
>
> Bill,
>
> All dates here are kept as yyyy-mm-dd.
>
> And each dataframe row has this format:
> 2015-10-01,00:00,90.6689
> 2015-10-01,01:00,90.6506
> 2015-10-01,02:00,90.6719
> 2015-10-01,03:00,90.6506
>
> Thanks,
>
>
> Rich
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list