Last data update: 2014.03.03

R: Store Discriptive Information About an Object
valueTagsR Documentation

Store Discriptive Information About an Object

Description

Functions get or set useful information about the contents of the object for later use.

Usage

valueTags(x)
valueTags(x) <- value

valueLabel(x)
valueLabel(x) <- value

valueName(x)
valueName(x) <- value

valueUnit(x)
valueUnit(x) <- value

Arguments

x

an object

value

for valueTags<- a named list of value tags. a character vector of length 1, or NULL.

Details

These functions store the a short name of for the contents, a longer label that is useful for display, and the units of the contents that is useful for display.

valueTag is an accessor, and valueTag<- is a replacement function for all of the value's information.

valueName is an accessor, and valueName<- is a replacement function for the value's name. This name is used when a plot or a latex table needs a short name and the variable name is not useful.

valueLabel is an accessor, and valueLabel<- is a replacement function for the value's label. The label is used in a plots or latex tables when they need a descriptive name.

valueUnit is an accessor, and valueUnit<- is a replacement function for the value's unit. The unit is used to add unit information to the R output.

Value

valueTag returns NULL or a named list with each of the named values name, label, unit set if they exists in the object.

For valueTag<- returns list

For valueName, valueLable, and valueUnit returns NULL or character vector of length 1.

For valueName<-, valueLabel<-, and valueUnit returns value

Author(s)

Charles Dupont

See Also

names, attributes

Examples

age <- c(21,65,43)
y   <- 1:3
valueLabel(age) <- "Age in Years"
plot(age, y, xlab=valueLabel(age))


x1 <- 1:10
x2 <- 10:1
valueLabel(x2) <- 'Label for x2'
valueUnit(x2) <- 'mmHg'
x2
x2[1:5]
dframe <- data.frame(x1, x2)
Label(dframe)


##In these examples of llist, note that labels are printed after
##variable names, because of print.labelled
a <- 1:3
b <- 4:6
valueLabel(b) <- 'B Label'

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Hmisc)
Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2

Attaching package: 'Hmisc'

The following objects are masked from 'package:base':

    format.pval, round.POSIXt, trunc.POSIXt, units

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Hmisc/valueTags.Rd_%03d_medium.png", width=480, height=480)
> ### Name: valueTags
> ### Title: Store Discriptive Information About an Object
> ### Aliases: valueTags valueTags<- valueLabel valueLabel<- valueUnit
> ###   valueUnit<- valueName valueName<-
> ### Keywords: attribute misc utilities
> 
> ### ** Examples
> 
> age <- c(21,65,43)
> y   <- 1:3
> valueLabel(age) <- "Age in Years"
> plot(age, y, xlab=valueLabel(age))
> 
> 
> x1 <- 1:10
> x2 <- 10:1
> valueLabel(x2) <- 'Label for x2'
> valueUnit(x2) <- 'mmHg'
> x2
Label for x2 [mmHg] 
 [1] 10  9  8  7  6  5  4  3  2  1
> x2[1:5]
Label for x2 [mmHg] 
[1] 10  9  8  7  6
> dframe <- data.frame(x1, x2)
> Label(dframe)
label(x1)	<- ''
label(x2)	<- 'Label for x2'
> 
> 
> ##In these examples of llist, note that labels are printed after
> ##variable names, because of print.labelled
> a <- 1:3
> b <- 4:6
> valueLabel(b) <- 'B Label'
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>