R barplot:xlim中不允许使用NA

时间:2019-06-30 19:36:36

标签: r

我试图如下图所示绘制x与y的关系

   test1 <- data.frame(x = c(26, 21, 20), y = c("a", "b", "c"))
   plot(test1$y,test1$x)

但是我得到以下错误。我该如何处理?

 Error in plot.window(xlim, ylim, log = log, ...) : 
 NAs not allowed in 'xlim'
 In addition: Warning messages:
 1: In mean.default(width) :
 argument is not numeric or logical: returning NA
 2: In Ops.factor(width, 2) : ‘/’ not meaningful for factors
 3: In Ops.factor(space, width) : ‘+’ not meaningful for factors
 4: In Ops.factor(width, 2) : ‘/’ not meaningful for factors
 5: In Ops.factor(space, width) : ‘+’ not meaningful for factors

1 个答案:

答案 0 :(得分:0)

我运行了您的代码,一切正常, 情节就是这样。Output Plot