You could specify the title (and also the title of the axes via xlab
and ylab
) with the main
option. E.g.:
plot(data[,i], main=names(data)[i])
And if you want to plot (and save) each variable of a dataframe, you should use png
, pdf
or any other graphics driver you need, and after that issue a dev.off()
command. E.g.:
data <- read.csv("sample.csv",header=T,sep=",")
for (i in 1:length(data)) {
pdf(paste('fileprefix_', names(data)[i], '.pdf', sep='')
plot(data[,i], ylab=names(data[i]), type="l")
dev.off()
}
Or draw all plots to the same image with the mfrow
paramater of par()
. E.g.: use par(mfrow=c(2,2)
to include the next 4 plots in the same "image".