2017-08-16 15 views
0

我将数据分组在列上,并尝试使用fitdistplus软件包来适合每个组的数据。在一些团体,我得到异常:抑制Shiny Server data.table中的异常和错误

功能MLE未能估计参数, 错误代码52

我想忽略这与其他群体的配件进行。我试过tryCatch,但它没有压制错误。有人可以帮助我吗?

感谢

fits <- df[!is.na(x) 
     , { 
     tryCatch({ 
      if(length(x) > 1){ 
      fit <- fitdist(c(x), distr="norm",method = "mle",lower=lower,upper=upper); 
      if(distribution_type == "exp" | distribution_type=="pois"){ 
       tempList<- list(est1 = fit$estimate[[1]],est3=.N); 
       names(tempList)<- c(names(fit$estimate[1]),"count"); 
       tempList 
      } 
      else{ 
       tempList<- list(est1 = fit$estimate[[1]], est2 = fit$estimate[[2]],est3=.N) 
       #print(names(fit$estimate[[1]]); 
       names(tempList)<- c(names(fit$estimate[1]),names(fit$estimate[2]),"count"); 
       tempList 
      } 
      } 
     },error = function(e){message(e)}) 
     } 
     , by = group_by_column] 

回答

0

我想我已经发现的错误。我正在打印message(e)作为发回给调用者的异常。

error=function(e){}工作。