1

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 
Tinniam V. Ganesh
  • 1,979
  • 6
  • 26
  • 51
  • Show us objects you're using. Have you tried to draw the example in help file of `pie3D`? Have you compared its inputs to yours and try to find the discrepancies between two datasets? – Roman Luštrik Feb 04 '15 at 13:26
  • @RomanLuštrik - I have added the code for pie3D. The error is unhelpful – Tinniam V. Ganesh Feb 04 '15 at 13:31
  • We don't have access to your data so it's hard to judge what's going on. You can either check on your own where the differences between the example and your data are, or you can give us a [small reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Roman Luštrik Feb 04 '15 at 13:33
  • @RomanLuštrik the data looks like this has 329 values. A small portion included. The problem is that the pie3D works in 5 and creates an issue in 1 of the cases. That is why it difficult to debug. Moreover the variables are internal. Not sure how to go about debugging. Thoughts - Ganesh – Tinniam V. Ganesh Feb 04 '15 at 13:36
  • 2
    I think the problem happens when you have more labels than slices, so you can `lbls` to `lbls <- unique(e)` to remove labels that have 0 values in the vector e – NicE Feb 04 '15 at 14:13
  • @NicE- Thx. You saved me many hours of grief. Once I ensured the the length of lbls and slices were same the pie3D worked. I did a lbls <- unique(e) as you mentioned. Many thanks! - Ganesh – Tinniam V. Ganesh Feb 04 '15 at 16:24

1 Answers1

1

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

Regards Ganesh

Tinniam V. Ganesh
  • 1,979
  • 6
  • 26
  • 51