Missing columns names when using sapply to pass a function

71 views Asked by At

I am trying to loop over the columns in a dataframe to get descriptives. Since some columns throw errors, I wanted to use tryCatch function to ignore the error & continue. For this purpose I use sapply and pass the formula.In this process, I lose the names of the columns. How do I get them? Thank you in advance.

    data(mtcars)
    names(mtcars)
    library(DescTools)
    wrd<-GetNewWrd()
    sapply(mtcars, function(fnm){tryCatch(Desc(fnm, plotit=TRUE, wrd=wrd),error=function(e) NULL)})
0

There are 0 answers