|Summary:||units<- drops names|
|Product:||R||Reporter:||Seth Roberts <twoutopias>|
Description Seth Roberts 2012-03-11 02:10:57 UTC
Using the units function with a difftime object changes other attributes. Here is an example: > t1=Sys.time() > t2=Sys.time() > t3=difftime(t1,t2) > t3 Time difference of -7.624 secs > names(t3)="test" > names(t3)  "test" > units(t3)="mins" > names(t3)  "secs"
Comment 1 Brian Ripley 2012-03-12 22:07:21 UTC
changed for as.vector to unclass for 2.15.0
Comment 2 Brian Ripley 2012-03-13 01:53:07 UTC
On 11/03/2012 01:10, firstname.lastname@example.org wrote: > https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14839 > > Summary: units function does not work properly > Product: R > Version: R 2.13.1 > Platform: x86_64/x64/amd64 (64-bit) > OS/Version: Windows 64-bit > Status: NEW > Severity: normal > Priority: P5 > Component: Language > AssignedTo: R-core@R-project.org > ReportedBy: email@example.com > Estimated Hours: 0.0 > > > Using the units function with a difftime object changes other attributes. Here > is an example: First, note that you are actually using the units<- function here, not units. Second, all I see about this is The units of a â€˜"difftime"â€™ object can be extracted by the â€˜unitsâ€™ function, which also has an replacement form. If the units are changed, the numerical value is scaled accordingly. and no claim that anything is preserved. And the presence of as.vector() in the code indicates that the author did not intend to preserve attributes. Picking up "secs" was almost certainly a mistake though. But to say it 'does not work properly' you need to demonstrate that it is documented to preserve other attributes. I don't see the evidence here. Finally, 2.13.1 is several versions old: you are asked only to report on current R (2.15.0 alpha now, since both the 2.13.x and 2.14.x series are closed). >> t1=Sys.time() >> t2=Sys.time() >> t3=difftime(t1,t2) >> t3 > Time difference of -7.624 secs >> names(t3)="test" >> names(t3) >  "test" >> units(t3)="mins" >> names(t3) >  "secs" > -- Brian D. Ripley, firstname.lastname@example.org 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