I would like to have a small function displaying basic data statistics for eachnumeric variable in a given dataset. So far I have the following:
AnalyzeNumericData <- function(x,GroupVar=NA) {
VarList <- names(x)
NumVars <- length(VarList)
for (i in (1:NumVars)) {
if (is.numeric(x[,VarList[i]])) {
par(mfrow=c(2,2))
hist(x[,VarList[i]],main=paste("Histogram of ",VarList[i]),xlab=NA)
boxplot(x[,VarList[i]],main=paste("Boxplot of ",VarList[i]))
if (!is.na(GroupVar)) {
boxplot(x[,VarList[i]]~x[,GroupVar],main=paste("Boxplot of ",VarList[i]," by ", GroupVar))
}
# Add some text to bottom right
# I've tried plot(1)
# and then text(1,"MyText"), but this only alows me to put text on one place (in the middle of the plot)
}
}
}
AnalyzeNumericData(mtcars,"cyl")
The function will create three charts for each numeric variable. I would like to add some text instead of the 4th chart to the bottom right area. I know of text(), however I have to create something like empty chart first in order to use this.
Any ideas appreciated.
You can change
xandyoftext(x,y,labels="MyText")to adjust position of the text according toxlimandylim.