2017-08-16 17 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){}工作。