I am trying to plot a piechart in R using data present in a data-frame.It is possible that the values can be zero at times.In this situation ,R is throwing an error How to overcome this issue?
slices<-c(pu1_500,pu501_1000,pu1001_2000)
cols <- c("red","blue","green")
percentlabels<- round(100*slices/sum(slices), 1)
pie3D(slices,main="piechart",col=cols,labels=percentlabels,explode=0.1)
legend("topright", c("1-500","501-1000","1001-2000"), cex=0.8,fill=cols)
here let us suppose that ' pu501_1000 ' has value 0,then i get the following error:
Error in if (length(by) && by == 0 && length(del) && del == 0) return(from) : missing value where TRUE/FALSE needed