[R] Error in if (n > 0)

David Winsemius dwinsemius at comcast.net
Thu Aug 23 01:22:57 CEST 2012


On Aug 22, 2012, at 3:59 PM, Rich Shepard wrote:

> On Wed, 22 Aug 2012, David Winsemius wrote:
>
>> It is not saying there are zero values for concentration.... it is  
>> saying there are groups with zero elements:
>
>  Thank you very much, David.
>
>>> table(cu.t$ceneq1, cu.t$era)
>>
>>      Mining Pre-mining
>> FALSE    723          0
>> TRUE     183          9
>
>  That's interesting. I did not realize that cenboxplot() (or cenros)  
> cannot
> accommodate only censored data in one era.

I'm not sure I understand why you think there should be any estimate  
when all of one group is censored?

> Sigh. I'll work around it.

In this case it appears that the plotting function is what threw the  
error:
 > cenboxplot(cu.t$quant, cu.t$ceneq1, cu.t$era, range=1.5, main='Total
+ Recoverable Copper', ylab='Concentration (mg/L)', xlab='Time Period')
Error in if (n > 0) (1L:n - a)/(n + 1 - 2 * a) else numeric() :
   argument is of length zero
 > traceback()
7: ppoints(obs)
6: hc.ppoints(obs, censored)
5: cenros(obs[group == i], cen[group == i])
4: cenros(obs[group == i], cen[group == i])
3: withCallingHandlers(expr, warning = function(w)  
invokeRestart("muffleWarning"))
2: suppressWarnings(cenros(obs[group == i], cen[group == i])$modeled)
1: cenboxplot(cu.t$quant, cu.t$ceneq1, cu.t$era, range = 1.5, main =  
"Total\nRecoverable Copper",
        ylab = "Concentration (mg/L)", xlab = "Time Period")

This succeeds in creating a plot

with( cu.t[cu.t$era=="Mining", ], cenboxplot(cu.t$quant, cu.t$ceneq1,  
range=1.5, main="Total Recoverable Copper", ylab="Concentration (mg/ 
L)", xlab="Time Period") )

-- 

David Winsemius, MD
Alameda, CA, USA




More information about the R-help mailing list