[R] Generating automatic plots

Xavier Fernández i Marín xavier.fim at eresmas.net
Wed Oct 8 12:05:31 CEST 2003


Hello,

I have been trying to write a small program to generate automatic plots. What 
I want is to draw boxplots for some variables in my data frame, contrasting 
with a variable called 'missing' that has value 1 if some variable in a 
concrete case has at least one missing value, in order to check if the cases 
that don't enter in my analysis are biased.

The first attempt was to start generating a list with the variables of 
contrast and then apply the list to the plots:

> varlist <- c("var1", "var2", "var3", "var4", ...)

> for (i in 1:length(varlist)) {
+  jpeg("varlist[i].jpg", width=480, heigth=480)
+  boxplot (varlist[i] ~ missing, xlab="missing values", ylab="varlist[i])
+  }

But I got 'Error in model.frame(formula, rownames, variables, varnames, 
extranames: invalid variable type'

I suppose that is because I forget something related to the extraction of 
values in vectors, but I can't find it on the R manual neither in other books 
about R that I have checked.

Is there a way to draw plots using commands like the one above?

Thanks,


Xavier




More information about the R-help mailing list