在R中绘图:获取线而不是点

时间:2016-01-15 01:36:58

标签: r plot

我有9个国家的9点数据:

var <- structure(list(countries = structure(c(1L, 9L, 6L, 5L, 3L, 4L, 
2L, 8L, 7L), .Label = c("BU", "CZ", "ES", "HU", "LT", "LV", "PL", 
"SL", "UK"), class = "factor"), Eurasian.lynx = c(NA, 0, 0.063, 
0, 0.028, NA, NA, 0.0415, 0.058), Grey.wolf = c(0, 0.048, 0.11, 
0.24, 0, NA, NA, 0, 0), Brown.bear = c(0, 0.0332, NA, NA, 0.032, 
NA, NA, 0, 0), Wild.boar = c(0.076, 0.03, 0.072, 0.058, 0.089, 
0, 0, 0, 0.064), Moose = c(NA, 0.04, 0.067, 0.086, 0.087, NA, 
NA, NA, 0.078), Red.deer = c(NA, 0.033, 0.039, 0.052, 0, 0, 0, 
0.0146, 0.03), Roe.deer = c(0.025, 0.037, 0.12, 0.08, NA, 0, 
0.02, 0.00938, 0)), .Names = c("countries", "Eurasian.lynx", 
"Grey.wolf", "Brown.bear", "Wild.boar", "Moose", "Red.deer", 
"Roe.deer"), class = "data.frame", row.names = c(NA, -9L))

我正试图在R中制作一个物种与国家。这是我的代码:

var = read.csv('variance.csv', header = T, sep = ',')
attach(var)
plot(Grey.wolf ~ countries, col = 'green',type = 'p', pch = 19, cex = 2.5,    ylab='',xlab='')

但是我得到了这些丑陋的线条而不是点数:enter image description here 我究竟做错了什么?  谢谢!

1 个答案:

答案 0 :(得分:0)

实际上,我刚刚找到了如何做到这一点:xyplot(Grey.wolf ~ countries, type='p', col = 'green', pch = 19, cex = 2.3, xlab = '', ylab = '')