Reputation: 1
I want to create a function in R that return to me the skewness and the kurtosis simultaneously from the vector y:
set.seed(1112);
y <- x <- 11 + sqrt(12) * rnorm(5000);
y[sample(x = 5000, size = 200, replace = F)] <- NaN;
Upvotes: 0
Views: 183
Reputation: 16876
You can use the functions from DescTools
to create a function to return both.
kurt_skew <- function(x){
skewness <- DescTools::Skew(y, na.rm=TRUE)
kurt <- DescTools::Kurt(y, na.rm=TRUE)
return(list(skewness = skewness, kurt = kurt))
}
kurt_skew(y)
#$skewness
#[1] -0.02903336
#$kurt
#[1] -0.01281097
Upvotes: 1