Why doesn't `ann = F` work when building with` as.factor` in R?

I draw a continuous variable with coefficient using plot() in R (see example below). I don't need marks on axes. Without calling as.factor in the ann = F formula, label printing is suppressed, but it does not work with as.factor in the formula.

Why is this?

Thanks.

 # example for SO # example data x <- sample(1:100, 10) y <- c(rep(1, 5), rep(2, 5)) # ann = F doesn't work here plot(x ~ as.factor(y), ann = F) # ann = F does work here plot(x ~ y, ann = F) 
+4
source share
2 answers

This seems to be called plot.formula because it works if you specify x and y separately:

 plot(as.factor(y), x, ann=FALSE) 

UPDATE:

Confirmation that it is in graphics:::plot.formula . The line that invokes plot explicitly sets ylab and xlab ( funname is "plot" and dots = list(ann=FALSE) ):

 do.call(funname, c(list(mf[[i]], y, ylab = yl, xlab = xl), dots)) 
+5
source

The sending system sends a non-working one to plot.factor, which then sends it to boxplot, which has no ann = argument, and a "working" one to plot.data.frame, which goes to plot.default in the end, which honors the ann = argument . To suppress naming. Application:

plot (x ~ as.factor (y), names = rep ("", 2))

+2
source

All Articles