Error while testing Shapiro Wilk on multiple dataframe columns

Asked

Viewed 21 times

1

I have three dataframes, a main one, with 2046 observations and two derivatives of these (with 1980 and 66 observations respectively) representing solvent and insolvent companies. All dataframes have 48 variables including identification and period, that is, I’m trying to perform the test in only 46 columns. In the full dataframe I can run the test normally, however, in the smaller dataframes the same error appears:

Error in FUN(X[[i]], ...) : all 'x' values are identical

The code I’m using for both smaller and larger dataframes is this:

Data_SW <- do.call(rbind, lapply(Data[c(3:41)], shapiro.test))
Data_SW <- data.frame(Data_SW)

One suggestion they gave me was this::

num <- which(sapply(Completo[3:50], is.numeric))
num <- intersect(3:50, num)

Completo_SW <- do.call(
  rbind.data.frame,
  lapply(Completo[num], function(x){
    tryCatch(shapiro.test(x)[c("statistic", "p.value")],
             error = function(e) e)
  })
)

But the error persists, what can I do to fix it? I appreciate any help!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.