1

当我调用 pie3D 时,我收到错误“if (labelsep < minsep) { : 需要 TRUE/FALSE 的缺失值”错误,并且代码退出。

我怎样才能解决这个问题。没有 if else 语句。这似乎是 pie3D 内部的。

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

任何帮助将不胜感激

问候 Ganesh


用代码更新。调用 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 < minsep) { 中的错误:需要 TRUE/FALSE 的缺失值

更新:小数据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 
4

1 回答 1

1

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

问候 Ganesh

于 2015-02-04T16:25:17.897 回答