我有一个数据,就是这样:
Metai World Lithuania Latvia Estonia
1995 19.99274674 3.664078576 5.165501237 6.19899916
1996 20.1618143 3.584610154 5.203743587 8.848114633
1997 21.34178618 3.792669688 6.25751733 9.131262925
1998 22.0383053 3.290601838 3.978832389 11.69820107
1999 23.07794571 3.296374656 4.060777075 13.49890414
2000 24.46391466 4.458263805 3.959122402 29.9304493
2001 22.97296394 4.990611202 3.772830006 19.28104368
2002 22.24335355 3.770408263 3.867904265 11.86431239
2003 21.15902664 4.790428512 4.58911383 12.65710496
2004 20.93194705 4.721934472 4.885990508 13.99565801
2005 20.64893325 6.153892776 5.314174985 14.66002177
2006 20.79146459 8.057471159 6.821101055 12.62826088
2007 17.5236718 10.84503636 6.947695298 5.801621676
2008 16.71189963 11.14479194 6.953299326 5.401508192
2009 18.15846464 9.994402174 7.758518211 5.679785009
2010 17.58191783 10.60837644 7.644312054 9.265320112
2011 16.52156487 10.21171712 8.242904557 13.38765176
2012 16.97066134 10.42150357 9.777651216 10.75136222
2013 17.04950642 10.33111769 13.01214609 10.50099872
我开始在我的课程中使用R,并想要一个看起来像这样的点图:preffered dotplot。所以我开始学习教程,到目前为止,我的代码看起来像这样。请忽略奇怪的命名 - 用我的语言和其他情节进行演示,我很好。
#nuskaitymas
ld4 <- read.csv(file="LD4.csv",head=TRUE,sep=",")
ld4
library(ggplot2)
library(tidyr)
laboras <- gather(ld4,
value="Procentai",
key="Salis",
World, Lithuania, Latvia, Estonia)
plotas1 <- ggplot(laboras, aes(x=Metai,y=Procentai, color=Salis)) + geom_line()
plotas1 + scale_y_continuous(breaks=seq(0,30,1)) + scale_x_continuous(breaks=seq(1995,2013,1))
plotas2 <- ggplot(laboras, aes(x="Salis", y="Procentai")) +
theme(legend.position="top", axis.text=element_text(size = 6))
(plotas21 <- plotas2 + geom_point(aes(color = Metai),
alpha = 0.5,
size = 6,
position = position_jitter(width = 1, height = 0.25)))
糟糕的是 - 无论何时我绘制,不仅我变得奇怪,而且看起来都不好 - 每次点都会改变位置,即使我的数据没有改变。看起来像这样:bad plot
我做错了什么?你能纠正我的代码吗?感谢