Search code examples
rskew

how to find the skewness of multiple columns and individually print the skew factor of a dataframe


How to find skewness of multiple columns of a dataframe in R withoug individually finding the skewness by writing skewness() multiple no. of times Instead using a loop or something else i can find the skewness i tried implementing this using R

for(i in length(numeric_val)) #numeric_val is a dataframe containing 38 cols and 1460 rows
 {
  if(skewness(as.numeric(unlist(numeric_val[i]))) > 0.75)
  {
    numeric_val[i] = log1p(numeric_val[i])
  }
 }

please anyone one help me out.


Solution

  • Maybe something like:

    sapply(df, function(x) ifelse(skewness(x) > 0.75, x <- log1p(x), x))