[R] Measurement units inside a data frame

Gavin Simpson gavin.simpson at ucl.ac.uk
Thu Feb 7 11:57:15 CET 2008


hits=-2.6 tests=BAYES_00
X-USF-Spam-Flag: NO

On Thu, 2008-02-07 at 19:32 +0900, Tribo Laboy wrote:
> Hello,
> 
> I was wondering if there was an easy way to put information about the
> measurement units used for each column of a data frame ...
> 
> Thanks for any pointers,
> 
> TL

You could add attributes:

dummy <- data.frame(x = rnorm(10), y = rbeta(10, 2, 5), z = rlnorm(10))
dummy

attr(dummy, "units") <- c("m s-2", "Kg", "m")
dummy
attributes(dummy)

G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list