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)})