An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20060911/8d93c9c8/attachment.pl
Passing dates from Excel to R using RExcel functions
4 messages · Paolo Rossi, Brian G. Peterson, Gabor Grothendieck +1 more
On Monday 11 September 2006 03:42, Paolo Rossi wrote:
I have the following problem using RExcel. When I use the VBA function "putarray" to put a vector of dates from Excel to R, I don't see the dates in R but the serial number converted to text. I don't know, then, how to trasform them in dates again... could anyone help me?
Excel denominates dates in days since 1 Jan 1970. You need to convert
those to a unix timestamp, and then convert them to a Date class in R.
I've never specifically had this problem directly in R, but I do have some
PHP code that you should be able to adapt to R to solve your problem.
if ($passed_date<2958465) { //this is an MS Excel date
//MS Excel denominates in days since 1 Jan 1970
$ts = ($passed_date - 25568) * 86400;
$formatted_date = date ( 'Y-m-d' , $ts);
}
Hope this helps,
- Brian
There is some discussion of Excel dates in the R Help article in R News 4/1.
On 9/11/06, Paolo Rossi <prossi79.r at gmail.com> wrote:
Good morning all,
I have the following problem using RExcel. When I use the VBA function
"putarray" to put a vector of dates from Excel to R, I don't see the dates
in R but the serial number converted to text. I don't know, then, how to
trasform them in dates again...
could anyone help me?
thank you very much
Paolo Rossi
[[alternative HTML version deleted]]
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance
2 days later
I have had no problems passing date in as dataframes back and forth and is now my prefered method.. No need to even do as.Date or know all the Posixct kungfu although it is worth knowing all that.. [Instead of rput I use rputdataframe and this works like a charm with zoo or the new Diethelm's timeSeries class .] Best, Krishna
Gabor Grothendieck wrote:
There is some discussion of Excel dates in the R Help article in R News 4/1. On 9/11/06, Paolo Rossi <prossi79.r at gmail.com> wrote:
Good morning all,
I have the following problem using RExcel. When I use the VBA function
"putarray" to put a vector of dates from Excel to R, I don't see the dates
in R but the serial number converted to text. I don't know, then, how to
trasform them in dates again...
could anyone help me?
thank you very much
Paolo Rossi
[[alternative HTML version deleted]]
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance