xiao.gang.fan1 at free.fr
2006-Nov-27 13:08 UTC
[Rd] as.Date: conversion pb from POSIXct (PR#9386)
Full_Name: Xiao Gang FAN Version: 2.4.0 OS: Windows Submission from: (NULL) (159.50.101.9)> library(chron) > as.Date(as.POSIXct(strptime("1994-01-24","%Y-%m-%d")))[1] "1994-01-23"
Gabor Grothendieck
2006-Nov-27 13:21 UTC
[Rd] as.Date: conversion pb from POSIXct (PR#9386)
as.Date is converting your object with respect to GMT time zone and in that time zone your POSIXct date is the day before. See ?as.Date and also suggest you read R News 4/1 help desk article. On 11/27/06, xiao.gang.fan1 at free.fr <xiao.gang.fan1 at free.fr> wrote:> Full_Name: Xiao Gang FAN > Version: 2.4.0 > OS: Windows > Submission from: (NULL) (159.50.101.9) > > > > library(chron) > > as.Date(as.POSIXct(strptime("1994-01-24","%Y-%m-%d"))) > [1] "1994-01-23" > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >
ripley at stats.ox.ac.uk
2006-Nov-27 13:46 UTC
[Rd] as.Date: conversion pb from POSIXct (PR#9386)
You have not told us your timezone, but this seems to be as documented if you are in CET. The help page says The 'as.Date' methods accept character strings, factors, logical 'NA' and objects of classes '"POSIXlt"' and '"POSIXct"'. (The last are converted to days by ignoring the time after midnight in the representation of the time in UTC.) ^^^^^^ Probably as.POSIXct(strptime("1994-01-24","%Y-%m-%d") is 1994-01-23 23:00 in UTC in your timezone. On Mon, 27 Nov 2006, xiao.gang.fan1 at free.fr wrote:> Full_Name: Xiao Gang FAN > Version: 2.4.0 > OS: Windows > Submission from: (NULL) (159.50.101.9) > > >> library(chron)Irrelevant.>> as.Date(as.POSIXct(strptime("1994-01-24","%Y-%m-%d"))) > [1] "1994-01-23"Not in my timezone. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Maybe Matching Threads
- pb in regular expression with the character "-" (PR#9437)
- strange behaviour in R 2.0.0 (PR#7275)
- Base R: applying min/max functions() to character string vectors (PR#9428)
- Release of Design library; update of Hmisc library
- Release of Design library; update of Hmisc library