# create data frame mydata (usually read from a file with rad)
n <- 12
X <- sample(c("Group1","Group2"), size=n, replace=TRUE)
Y <- rnorm(n=n, mean=50, sd=10)
mydata <- data.frame(X,Y)
rm(X); rm(Y);
# create data frame mylabels (usually read from a file with rad)
# The labels themselves are a variable named \code{label}, but
# this information is only necessary if constructing the
# labels data frame manually, such as is done here.
vname <- character(length=2)
vname[1] <- "X"
vname[2] <- "Y"
label <- character(length=2)
label[1] <- "Group"
label[2] <- "Response"
mylabels <- data.frame(label)
row.names(mylabels) <- vname
# variable label as the title of a graph from a standard R function
# the data are not attached, so for standard R functions, must
# identify the relevant data frame, such as with function: with
with(mydata, barplot(table(X), main=label(X)))
with(mydata, hist(Y, main=label(Y)))
Run the code above in your browser using DataLab