[R] Generating automatic plots

Achim Zeileis zeileis at ci.tuwien.ac.at
Wed Oct 8 12:49:42 CEST 2003


On Wednesday 08 October 2003 12:05, Xavier Fernández i Marín wrote:

> 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)

here you want

  paste(varlist[i], ".jpg", sep = "")

> +  boxplot (varlist[i] ~ missing, xlab="missing values",

and here
  mydataframe[, varlist[i]] ~ missing

hth,
Z

> 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
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list