#round(skew(attitude),2)
## The function is currently defined as
function (x, na.rm = TRUE) {
if(length(dim(x))==0) {
if (na.rm) { x <- x[!is.na(x)] } #remove missing values
sum((x - mean(x))^3)/(length(x) * sd(x)^3) #calculate skew for a vector
} else { apply(x,2,function(x) sum((x - mean(x,na.rm=na.rm))^3,na.rm=na.rm)/( (length(x)-sum(is.na(x)) )* sd(x,na.rm=na.rm)^3)) } }
Run the code above in your browser using DataLab