geom_smooth没有显示任何结果

时间:2016-06-09 12:29:13

标签: r ggplot2

我正在努力生成一个情节(代表我在一组7行中的数据(1表示平均值,2表示+/-表示1 SD,2表示+/-表示2 * SD,2表示+/-表示3 * SD)。我在文档中找到了geom_smooth,但在R中运行它时没有给我任何消息,但它也没有产生任何结果。

我正在使用的数据子集:

TP  igg1_g0f    igg1_g1f    igg1_g2f    igg1_g0fn
4   7.694875072 25.1766502  26.71366572 1.606781989
-2  NA  NA  NA  NA
-2  NA  NA  NA  NA
7   21.12846485 29.38100992 13.98057732 7.605150351
6   26.91647951 27.69424842 12.11763841 7.294505055
-2  NA  NA  NA  NA
-2  NA  NA  NA  NA
3   9.763619447 26.50101856 23.96653701 2.185177747
1   28.89480444 31.42264281 13.46135768 3.680923924
2   11.86061004 27.05708477 21.3939814  2.071346427
6   11.27778505 32.30022662 21.26171845 2.262238509
3   8.923664688 26.94821964 25.02241493 1.734405384
-2  NA  NA  NA  NA
4   15.42562274 30.68111943 20.26957314 2.587605082
5   11.50528434 30.61618524 21.54428845 2.52030753
7   10.92344498 31.44856506 21.12307542 2.441455968
6   18.753654   28.93315901 14.15276041 5.872125839
7   23.00298067 27.99827666 13.75357126 6.586007896
2   11.08791626 29.2173996  22.29911851 2.214336902
3   11.68395859 25.01327035 24.74096189 2.718526263
7   41.47863817 27.14269737 7.73473192  5.714779156
7   8.600364919 25.28075808 23.29069717 2.752693473
7   7.869260481 25.97257118 23.94615049 2.075780712
6   13.02060798 32.04674799 19.95791733 3.120245386
6   20.16186669 31.98111067 13.76078237 6.026013476
6   39.85836764 28.90724998 8.038991751 5.039737963
5   11.50731669 31.09392282 20.89727391 2.523029855
3   29.06764423 29.23034962 14.40114131 3.005660972
4   8.2946921   26.15577713 25.64405115 1.588045744
7   14.99702137 30.11628424 19.02122196 4.043040521
4   31.71181337 29.09799264 12.92456505 3.002285246
3   12.04438268 28.17673514 21.90229944 2.878807843
4   10.63709695 26.18165724 23.55437329 2.679590479
3   9.936002953 25.70869164 23.34431291 1.703521429
5   8.227866441 24.54940667 22.05947182 2.863958188
5   13.82787239 33.16668736 19.26142779 2.727565599
3   17.68647738 28.36743915 18.44285562 4.070822732
7   21.6298296  28.92662255 13.64475144 6.233932123
5   19.5067981  31.45270674 14.48451816 5.083196574
5   9.512532911 27.32818859 24.5284004  2.713507549
3   6.929165327 26.45868981 30.07909631 1.127622042
2   25.93640232 28.28581707 16.63659972 3.073604564
6   10.98210663 29.06271352 22.64672025 2.97252144
5   11.1079932  30.02497948 20.02896132 2.30781207
2   16.16496982 29.71495669 18.34250885 4.399146498
1   22.57188686 30.23137665 13.00076583 6.529327609
2   12.93149261 29.84620166 27.02779681 2.641448868
6   12.70957951 31.95758801 21.71418425 2.793424293
3   43.12990389 24.33522891 10.34517851 4.608662754
6   7.685278847 25.87062837 23.63259792 2.021101262
4   4.035969156 16.97236308 30.31158514 1.371440552
4   10.14934162 24.0243324  25.5529779  2.755634509
2   6.238318003 21.11348188 28.25694075 0.893557593
5   25.15716941 28.72574346 12.26399794 6.798335428
6   25.20273517 31.01752748 15.09207021 4.181852491
6   14.24301669 34.16265796 18.49270565 3.089702836
6   8.996768092 26.84839182 21.6979002  2.45578168
7   12.43165647 30.40732037 22.53542683 2.734283838
6   10.07309221 27.83534311 20.72011742 3.274193579
7   41.13863078 28.16885408 6.981433716 4.281777971
7   13.43006747 28.08400305 20.05367064 3.637680703
5   16.30247684 31.36613092 16.01997256 5.386470812
3   6.700822843 26.61485451 27.06218416 1.568375265
4   13.48777584 27.34529173 21.67334322 3.580889713
4   11.50882279 30.40671302 26.0840906  1.841249999
7   15.88734105 31.16715853 18.39382354 3.083949137
3   11.39261924 30.65280415 25.22910674 1.93626508
3   10.51263592 26.07142579 25.96658356 1.993860526
4   17.73772147 28.71025297 18.47491736 4.514944468
2   20.11203672 29.80711751 16.2753095  4.339735431
4   16.69588662 28.33748306 18.63891508 3.968707643
7   12.91911174 31.03844665 18.44077823 2.771201635
6   12.71742038 31.48482461 21.38302678 2.551743091
4   6.974486406 22.41441159 28.52107629 1.394422153
1   50.6485388  22.08414147 7.454614402 5.985895163
6   10.77059915 29.2998256  23.23387531 2.614780354
7   13.24479018 29.93129137 21.80664173 3.658320851
2   12.45569107 32.369927   24.44717099 2.116596323
4   17.77951253 25.74666109 17.30032291 5.872184427
6   18.62282138 32.34700009 17.18967052 4.737612686
4   5.616692495 25.22462898 28.32025548 1.353685883
5   11.60361998 30.00462654 22.94583376 2.270946312
3   7.426187728 22.80149155 28.19896211 1.527918651
7   17.02681915 25.80656752 20.15253847 5.919637995
3   15.3931468  28.72137476 19.83508672 3.839321642
6   19.33028375 30.78367947 14.47123784 5.398131986
5   24.22570362 28.52187687 13.29357135 7.742613645
5   39.37946314 26.32033929 8.494283652 7.269625567
3   19.08793367 29.20927377 17.52674771 4.270165719
3   4.001342425 16.159415   29.38709146 1.291062246
6   16.53452173 30.98781746 19.85489033 4.327292584
4   36.9701772  25.74024913 11.42565008 5.375428666
7   15.4481142  31.10958805 19.18833522 4.50581224
5   7.261914385 25.50559563 24.67409686 1.794151257
2   39.54734248 24.73154058 11.9860036  5.139235422
5   18.02074719 32.17600195 17.61102626 4.521768032
4   12.84106725 25.56084271 20.22860233 3.704483409
2   12.14905715 20.94721494 20.43845999 4.111857626
6   6.161809329 24.55519968 23.34999629 1.892616086
2   12.2142052  28.55632982 22.0695689  2.922368548
3   11.27350823 18.98557348 22.20744736 3.927069159
2   9.689675076 27.131854   24.43439161 1.984634874
7   36.06002134 28.54113122 9.985244477 6.845640227
1   16.68970106 27.66510862 21.02738493 3.456740969
6   26.48121626 28.21359659 12.08003322 7.873293321
7   14.43096343 25.26556551 17.48538103 5.03951001
3   8.790467262 28.25722837 28.37361113 1.589091966
-1  NA  NA  NA  NA
3   NA  NA  NA  NA
2   4.797308518 17.23963803 28.42304342 1.546375535
4   9.22903135  24.76550222 23.85553097 1.722872095
7   14.7134782  34.4470481  21.30368351 2.795291432
2   7.70560164  27.8308971  29.15360069 1.282256054
7   17.46146672 29.04444123 19.80564855 3.997932496
3   5.670096303 19.93835874 29.27241136 0.784016297
6   8.913243765 28.93796687 22.5370239  2.395644844
4   3.068313929 15.53911739 30.04370328 0.918508912
2   8.582546883 24.22222784 27.35419244 1.892943844
5   11.24909832 25.76277692 20.45366236 3.380959719
7   10.69176841 32.63441908 23.86320541 2.063559367
4   8.496849746 21.24254916 25.01988024 2.507459339
7   10.38548486 28.44036828 23.66635789 2.896027274
7   11.30617161 32.98535121 19.80276219 2.912291665
5   34.05286125 30.13648733 10.82034739 4.739911989
2   9.046510075 24.50284232 24.86850251 1.864758672
3   16.38177573 25.60743821 17.93871389 4.800657589
6   9.651191691 32.62974489 24.85967928 1.809800703
5   14.25590746 28.67276598 20.62230353 4.31766964
0   NA  NA  NA  NA
7   9.167132669 25.88981322 24.63508212 1.67475964
7   15.91201816 27.59346287 20.84025318 4.131210505
2   10.86705145 31.19306568 25.84791476 1.927978847
4   13.0094459  28.3920555  20.87383561 2.52577269
4   8.071426957 24.94245608 29.10931436 1.445204075
7   7.626887167 26.55987363 24.79733963 1.888981847
5   15.76385808 34.87469581 21.08357198 2.676965272
1   38.42719623 29.39369665 8.100411204 3.970747479
6   12.67786605 31.47841818 18.32209338 2.83322453
7   26.87304275 31.10503711 14.33431107 4.278797822
5   6.036139209 23.62207526 24.89356302 1.707148896
3   8.088991307 22.751841   25.17375096 1.677084599
2   11.78077712 29.5928932  21.20230026 2.222848541
2   22.16674642 26.41646977 14.59593578 6.24734723
4   9.758858377 27.13541448 23.00008403 2.007330389
5   7.730013607 25.76031317 26.11382529 1.091324703
5   8.736965998 27.33696343 21.08134244 2.253414007
6   12.64752631 27.22690125 18.23320118 3.936394695
7   26.36771681 27.50215697 12.85023914 7.157241675
5   10.50049205 28.92360806 22.37292678 2.328442158
6   15.61360656 34.06324624 20.91342054 2.874477634
5   10.49193228 28.58071744 23.153226   2.080195603
5   9.170438488 30.45506183 22.65605265 2.311957607
5   34.71092667 30.19251921 8.831295445 4.266784876
3   30.32570199 31.04312845 12.85380164 2.676271556
4   8.650522042 28.47529066 28.18562872 1.574603877
4   5.373248505 19.48812519 29.57642902 0.734620792
3   13.44767663 28.47197317 24.42460223 3.224351643
7   21.83136018 30.42022468 13.50109781 5.758649837
7   13.90790261 33.38149405 21.59392669 3.202753941
5   15.03689095 31.13110238 20.66785356 2.815120286
4   7.834777248 24.40280347 26.62221357 1.59268633
6   10.11713324 31.74683865 20.3952316  2.771543856
4   9.998718587 25.35917198 26.71491652 1.868811537
2   6.260633376 22.85557815 25.53204191 1.559951153
4   5.194441665 19.1949153  28.95153004 1.13448663
2   5.306711577 19.24027326 28.57397931 1.844579754
1   25.2683476  27.2671659  12.08414255 7.319991981
5   13.70598713 32.57781149 20.63110607 3.173155645
3   5.055580106 20.91312611 26.66589749 1.280965619
2   9.371202816 27.13794571 26.96554941 2.293140976
5   13.19171305 32.66924998 19.34377786 2.194344897
2   6.927341836 22.64958607 26.59481155 1.683855191
5   11.64788741 33.15935125 23.47795579 2.349620494
3   8.504020882 25.15461644 25.87152744 1.726362667
1   11.39748115 32.7625887  24.40097548 2.224429374
3   5.987674735 20.48614233 27.96283624 1.367148308
3   10.5723569  26.74996963 26.59831848 2.05149724
5   12.542091   30.29916968 21.39618567 3.024947975
2   9.088194779 25.63396147 21.7974755  2.252297229
4   23.48652777 29.45066776 15.47820465 2.709074951
6   8.886420401 27.60011858 25.13212279 1.325350879
2   31.51495726 31.38022701 10.72969457 3.065577651
6   11.76118631 33.5661711  22.72863256 2.413243327
4   11.45283466 23.78676653 24.24738777 3.876095343
4   4.661606655 20.57259127 26.5887576  1.152304385
2   23.69082177 26.27707118 17.64762146 4.148809349
5   9.254171413 31.8754942  25.15861422 1.699256182
3   13.74989096 29.37418005 20.67046273 2.649745741
2   16.81875874 29.73844914 21.9991776  3.722615409
6   14.14221478 32.531745   17.96269699 2.524915892
6   12.11558133 30.94112591 20.80929929 2.623822004
2   8.717065249 22.31307387 27.71668859 2.527585845
1   12.44150215 30.98314379 23.13634258 3.113776932
7   7.991944872 23.27662553 24.59995733 2.659539825
4   7.59679809  22.03603536 26.36476691 1.533750086
3   21.4010817  25.73006707 19.8268147  3.725818317
2   14.86404641 30.16704314 19.01164835 2.921418801
4   7.960809875 23.95664452 29.64476906 2.047417875
2   8.96571205  29.28083674 23.88645145 2.184156173
6   17.16466257 33.13185648 18.26085907 3.592038505
4   14.19222856 25.71761125 23.56081479 2.841410697
7   18.03536849 31.52007655 15.30512293 3.948928924
3   7.691738195 21.55999008 28.22751541 2.155065969
3   7.958529254 24.62078017 29.1257356  1.968037234
2   6.894041089 23.57460368 26.77039449 1.601901612
6   16.31818694 30.70074632 17.71774237 3.309025121
4   7.824770573 23.19975836 24.50831799 1.721836577
7   11.5275751  26.5570782  22.26184366 2.702735664
2   8.270393885 25.08762197 27.66950024 1.589900289
3   7.836344817 25.00029357 29.68317768 1.35965523
3   8.435016154 23.55572837 23.51669749 1.941897004
7   12.56023971 28.32228649 20.94022644 3.312546093
1   10.67321778 30.70884808 21.34564395 2.837383822
6   11.09338276 28.31692565 19.59394908 2.846027461
5   10.40691698 26.28176137 21.67356901 2.222063275
5   9.554956862 27.51167982 21.66602696 2.343541814
6   10.68797215 26.56520956 22.1133696  2.469547316
-1  NA  NA  NA  NA
5   16.18530393 31.47629248 17.5631865  3.160043706
3   8.594323458 22.09233461 26.54764463 2.405271901
7   11.55204384 27.32094666 20.744936   2.704316139
4   7.528555763 20.29627021 27.57188635 2.323015638

我现在正在使用的代码

#install.packages("ggplot2")
library("ggplot2")

# Load Data
#test<-read.table("D:\\Users\\Bas\\Papers\\PARA\\Figure_Creation\\160512_PARA_subset.txt",header=TRUE)
test<-read.table("D:\\Users\\Bas\\Papers\\PARA\\Figure_Creation\\Mini.txt",header=TRUE)
attach(test)
TP = factor(TP,levels=c(1,2,3,4,5,6))

# Topographical plot
pdf("D:\\Users\\Bas\\Papers\\PARA\\Figure_Creation\\Topographical_SD.pdf")
for (i in colnames(test)[2:3]){
    print(ggplot(,aes_string(x="TP", y=i)) +
        #geom_point(na.rm = TRUE) + 
        geom_smooth(na.rm = TRUE))
}
dev.off()

geom_point行只是为了验证绘图本身是否有效。

因此,问题是我做错了什么,是否有更好的方法来产生这样的情节?

0 个答案:

没有答案