# 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)
vname <- character(length=2); vname[1] <- "X"; vname[2] <- "Y"
label <- character(length=2)
label[1] <- "Grouping Variable"
label[2] <- "Response Variable"
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 identify using the with function
with(mydata, barplot(table(X), main=label(X)))
with(mydata, hist(Y, main=label(Y)))
Run the code above in your browser using DataLab