点阵图这是低于绘图中的R
dput(test21)
structure(list(Freq = c(9L, 7L, 7L, 4L), MonthAbb = c("Jan",
"Feb", "Mar", "Apr")), .Names = c("Freq", "MonthAbb"), row.names = c(NA,
-4L), class = "data.frame")
我知道如何使用这些数据来创建一个barplot我的数据集,但是,我很感兴趣,下面
创建散点图这样要做到这一点一种方法是如下
a1 = seq(1, 9, length.out = 9)
a2 = rep(LETTERS[1], 9)
a = cbind(a1,a2)
b1 = seq(1, 7, length.out = 7)
b2 = rep(LETTERS[2], 7)
b = cbind(b1,b2)
c1 = seq(1, 7, length.out = 7)
c2 = rep(LETTERS[3], 7)
c= cbind(c1,c2)
d1 = seq(1, 4, length.out = 4)
d2 = rep(LETTERS[4], 4)
d= cbind(d1,d2)
test21a = as.data.frame(rbind(a,b,c,d))
test21a$a1 = as.numeric(test21a$a1)
ggplot(data = test21a, aes(x=a2, y=a1, color = a2)) + geom_point()
但是,这是非常ineffici恩,我正在手动创建一个数字序列。有兴趣了解是否有更好的方法来做到这一点。
是否有要这样还是会像'dotchart( test21 $ Freq,labels = test21 $ MonthAbb,pch = 20,col = c('red','blue','green','gray'))'do? – steveb
@steveb,我可以做你使用'ggplot(data = test21,aes(x = MonthAbb,y = Freq))+ geom_point()'提到的内容,但这不是我想到的。 –