f <- as.factor(sample( rep(c("a", "b", "c"), 3)))
plot(1:9,f)
gives the values 1.0..3.0 on the y-axis.
在y轴上给出1.0. 3.0的值。
How do I get the values of f ("a", "b" and "c") on the y-axis?
如何在y轴上得到f (a, b, c)的值?
2 个解决方案
#1
2
f <- as.factor(sample( rep(c("a", "b", "c"), 3)))
R base
R基
plot(1:9, f, yaxt = "n")
axis(2, 1:3, levels(f))
lattice
晶格
see fdetsch answer
ggplot2
ggplot2
library(ggplot2)
qplot(seq_along(f), f)
#1
2
f <- as.factor(sample( rep(c("a", "b", "c"), 3)))
R base
R基
plot(1:9, f, yaxt = "n")
axis(2, 1:3, levels(f))
lattice
晶格
see fdetsch answer
ggplot2
ggplot2
library(ggplot2)
qplot(seq_along(f), f)