I am plotting a continuous variable against a factor using plot() in R (see example below). I do not want the labels on the axes. Without the as.factor call in the formula ann = F suppresses the printing of the labels but it doesn’t work with as.factor in the formula.
Why is this?
Thank you.
# 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)
It seems to be caused by
plot.formulabecause it works if you specifyxandyseparately:UPDATE:
Confirmation that it’s in
graphics:::plot.formula. The line that callsplotexplicitly setsylabandxlab(funnameis"plot"anddots=list(ann=FALSE)):