Re: [R] Measurement units inside a data frame

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Thu, 7 Feb 2008 05:59:26 -0500

Here are 3 possibilities where the examples use the builtin data set BOD: #1. Use column headings

> names(BOD) <- paste(names(BOD), c("days", "mg/l"), sep = "_")
> BOD

  Time_days demand_mg/l

1         1         8.3
2         2        10.3
3         3        19.0
4         4        16.0
5         5        15.6
6         7        19.8

#2. add a "units" attribute to each column

> attr(BOD$Time, "units") <- "days"
> attr(BOD$demand, "units") <- "mg/l"
> attr(BOD$Time, "units")

[1] "days"

#3. See ?units in the Hmisc package which basically does #2 for you.

library(Hmisc)
example(units)

On Feb 7, 2008 5:32 AM, Tribo Laboy <tribolaboy_at_gmail.com> 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,



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 07 Feb 2008 - 11:13:42 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 07 Feb 2008 - 11:30:12 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive