简体   繁体   中英

plotrix:pie3d: Error in if (labelsep < minsep) { : missing value where TRUE/FALSE needed

When I call pie3D I get the error "Error in if (labelsep < minsep) { : missing value where TRUE/FALSE needed " and the code exits.

How can I fix this. There is no if else statement. This appears to be internal to pie3D.

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

Any help will be appreciated

Regards Ganesh


Update with code . The code exist when call pie3D with the error. The error is not helpful and seems to refer to internal variables of pie3D. The code works for several cases except 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)

Error here Error in if (labelsep < minsep) { : missing value where TRUE/FALSE needed

Update : small data 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 

As suggested by @NicE above ensure that the labels and slices are of same length. The problem then goes away.

Regards Ganesh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM