【问题标题】:plotrix:pie3d: Error in if (labelsep < minsep) { : missing value where TRUE/FALSE neededplotrix:pie3d: if (labelsep < minsep) { : 需要 TRUE/FALSE 的缺失值
【发布时间】:2015-02-04 13:24:25
【问题描述】:

当我调用 pie3D 时出现错误 “if (labelsep

我该如何解决这个问题。没有 if else 语句。这似乎是 pie3D 内部的。

pie3D(slices, labels=lbls,explode=0.2, main= atitle)

任何帮助将不胜感激

问候 象头神


使用代码更新。调用 pie3D 时出现错误代码。该错误没有帮助,似乎是指 pie3D 的内部变量。该代码适用于除 1 之外的几种情况。

d <- batsman$Dismissal
e <- d[ d != "-"]
lbls <- c("bowled","caught","hit wicket","lbw","not out", "retired not out", 
"run out")
 slices <- as.vector(table(e))
 slices <-  slices[slices != 0]
 pct <- round(slices/sum(slices)*100)
 lbls <- paste(lbls, pct) # add percents to labels 
 lbls <- paste(lbls,"%",sep="") # ad % to labels 
 atitle <- paste("Pie chart of dismissals for ", name)
 labelsep<-0
 minsep <- 1
 pie3D(slices, labels=lbls,explode=0.2, main= atitle)

这里有错误 错误 if (labelsep

更新:小数据 d

  [1] bowled  lbw     run out bowled  lbw     caught  caught  caught  
     caught  caught  bowled  caught  caught 
  [14] not out caught  lbw     bowled  caught  caught  caught  not out lbw
       lbw     caught  caught  caught 

【问题讨论】:

  • 向我们展示您正在使用的对象。您是否尝试在pie3D 的帮助文件中绘制示例?您是否将其输入与您的输入进行了比较,并尝试找出两个数据集之间的差异?
  • @RomanLuštrik - 我添加了 pie3D 的代码。该错误无济于事
  • 我们无权访问您的数据,因此很难判断发生了什么。您可以自行检查示例和数据之间的差异在哪里,也可以给我们small reproducible example
  • @RomanLuštrik 数据看起来有 329 个值。包括一小部分。问题是 pie3D 在 5 中工作并在其中 1 种情况下产生问题。这就是为什么它难以调试的原因。此外,变量是内部的。不知道如何进行调试。想法 - Ganesh
  • 我认为当标签多于切片时会出现问题,因此您可以 lblslbls &lt;- unique(e) 删除向量 e 中值为 0 的标签

标签: r plotrix


【解决方案1】:

正如上面@NicE 所建议的,确保标签和切片的长度相同。然后问题就消失了。

问候 象头神

【讨论】:

    猜你喜欢
    • 2019-03-07
    • 1970-01-01
    • 1970-01-01
    • 2021-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多