Using some of the tips above (especially thanks @daroczig for the names(df)[i]
form) this function prints a histogram for numeric variables and a bar chart for factor variables. A good start to exploring a data frame:
par(mfrow=c(3,3),mar=c(2,1,1,1)) #my example has 9 columns
dfplot <- function(data.frame)
{
df <- data.frame
ln <- length(names(data.frame))
for(i in 1:ln){
mname <- substitute(df[,i])
if(is.factor(df[,i])){
plot(df[,i],main=names(df)[i])}
else{hist(df[,i],main=names(df)[i])}
}
}
Best wishes, Mat.