[R-SIG-Finance] write.csv conversion problem
Martin Maechler
maechler at stat.math.ethz.ch
Thu Mar 10 19:08:04 CET 2016
>>>>> Roger J Bos <roger.bos at gmail.com>
>>>>> on Thu, 10 Mar 2016 05:50:04 -0500 writes:
> Peter,
> Dates are always stored as integers, so that is expected.
but what you say, Roger, is not correct. They *are* integer
valued, but they are double --- so that they will not suffer
from integer overflow for dates in the distant past or future:
> str(unclass(print(as.Date(Sys.Date()))))
[1] "2016-03-10"
num 16870
^^^
Martin Maechler, ETH Zurich
> You would need to use as.character() to convert
> the date before you output it to the file, but then it
> won't be of type double.
> Also, thee is a general r-help list where these types of questions should go.
> Thanks,,
> Roger
> On March 10, 2016, at 5:44 AM, Peter Neumaier <peter.neumaier at gmail.com> wrote:
> Hi all,
> I am writing a matrix (typeof = double) into a CSV file with write.csv.
> My first column of the matrix is a date in the form yyyy-mm-dd hh:mm:ss:
>> a_fetchdata[1,0]
> 2016-02-09 07:30:00
>> typeof(a_fetchdata[1,0])
> [1] "double"
> My CSV file contains a sequence of integers (from 1 to x) instead of the
> expected date.
> How can I prevent that conversion to happen when writing into CSV?
> Thanks
> Peter
> [[alternative HTML version deleted]]
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
More information about the R-SIG-Finance
mailing list