[R] Read in data table, change columns from factors

David Winsemius dw|n@em|u@ @end|ng |rom comc@@t@net
Thu Jul 19 01:32:28 CEST 2018


> On Jul 18, 2018, at 4:07 PM, Rich Shepard <rshepard using appl-ecosys.com> wrote:
> 
> On Wed, 18 Jul 2018, David Winsemius wrote:
> 
>> I would not destroy the possibility of using the original values:
> 
> David,
> 
>  What are the benefits of keeping date and time as factors?
> 
>>> allyears$myDate <- as.Date(as.character(allyears$date))
>>> allyears$myTime <- as.POSIXct(paste(allyears$date, allyears$time))


It's not so much as factors but rather in a form that paste() will coerce to character so you cna get the automatic format

> 
>  The latter command is not working on the full (402415 rows in the allyears
> data set):
> 
> allyears$myTime <- as.POSIXct(paste(allyears$date, allyears$time))
> Error in as.POSIXlt.character(x, tz, ...) :
>  character string is not in a standard unambiguous format

Maybe you need to add a format string. It might force some of your pasted date+time values to NA but at least you would be able to identify the original values and perhaps fix errors.

You really should include a large snapshot of data that will allow reproducibility.


> 
>> It's spelled `as.numeric`,
> 
>  Ah, I missed that. Thank you.
> 
>> ... but I'm having difficulty thinking about what sort of elevation (or would
>> that be "depth") would be be measured by "-3762938880000000369098752".
> 
>  I also was curious about that figure and grep doesn't find it in the
> original data file so I've no idea where R-3.5.0 came up with it.
> 
>  I'll read more about the POSIX datetime functions.
> 
> Thanks again,
> 
> 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/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   -Gehm's Corollary to Clarke's Third Law




More information about the R-help mailing list