lorenzo.logi at hsbc.fr
2006-Aug-07 15:05 UTC
[R] unwanted conversion of date formats in 2.3.1 to character
good morning I'm using R 2.2.1 on windows (2000/NT/XP) and trying to upgrade to 2.3.1 I am finding the curious problem of date/time data (both if stocked as date and as POSIX) that gets converted into character format whenever touched: it seems that date/time data just does not want to remain that way. For example, a data.frame containing dates or POSIXct as row.names that is returned as result from a function arrives to the calling function with characters as row.names: pippo<-function(...) { result<-data.frame( ... ) attributes(result)$row.names<- ... (some dates or POSIX) #mode(attributes(xx)$row.names) is now numeric, = date or POSIX return(result) } xx <- pippo(...) #mode(attributes(xx)$row.names) is now character !!!! This is new to 2.3.1 (and to 2.3.0 i suppose), i.e. everything worked like a charm in 2.2.1; it looks like a bug to me (but might notbe), and I have not been able to find any reference to such a problem in the archives (which is strange, but I might have got blind). Any idea pls? Thanks a lot in advance Ensemble adoptons des gestes responsables : N'imprimez ce mail que si necessaire. Les informations contenues dans ce message et les pieces jointes (ci-apres denomme le message) sont confidentielles et peuvent etre couvertes par le secret professionnel. Si vous n'etes pas le destinataire de ce message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez recu ce message par erreur, nous vous remercions de le supprimer de votre systeme, ainsi que toutes ses copies, et d'en avertir immediatement HSBC France et ses filiales par message de retour. Il est impossible de garantir que les communications par messagerie electronique arrivent en temps utile, sont securisees ou denuees de toute erreur, alteration, falsification ou virus. En consequence, HSBC France et ses filiales declinent toute responsabilite du fait des erreurs, alterations, falsifications ou omissions qui pourraient en resulter. Consider the environment before printing this mail. The information contained in this e-mail is confidential. It...{{dropped}}
Prof Brian Ripley
2006-Aug-07 15:45 UTC
[R] unwanted conversion of date formats in 2.3.1 to character
Row names of data frames are supposed to be character: if this worked in 2.2.1 it was a bug there. attributes(result)$row.names<- is not the way to assign an attribute (attr("row.names") <- is) and definitely not the way to assign row names (row.names(xx) <- is), and this may explain how you managed to circumvent the checks until now. On Mon, 7 Aug 2006, lorenzo.logi at hsbc.fr wrote:> > good morning > I'm using R 2.2.1 on windows (2000/NT/XP) and trying to upgrade to 2.3.1 > > I am finding the curious problem of date/time data (both if stocked as date and as POSIX) that gets converted into character format whenever touched: it seems that date/time data just does not want to remain that way. > > For example, a data.frame containing dates or POSIXct as row.names that is returned as result from a function arrives to the calling function with characters as row.names: > pippo<-function(...) { > result<-data.frame( ... ) > attributes(result)$row.names<- ... (some dates or POSIX) > #mode(attributes(xx)$row.names) is now numeric, = date or POSIX > return(result) > } > > xx <- pippo(...) > #mode(attributes(xx)$row.names) is now character !!!! > > This is new to 2.3.1 (and to 2.3.0 i suppose), i.e. everything worked > like a charm in 2.2.1; it looks like a bug to me (but might notbe), and > I have not been able to find any reference to such a problem in the > archives (which is strange, but I might have got blind). > > Any idea pls? > Thanks a lot in advance-- 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