I have the following data set
mydata <- datasets::volcano
install.packages('e1071')
library(e1071)
library(tidyverse) #load required libraries
head(mydata) # quick view of the data.
#Part 1
#Calculating kurtosis and new measure with apply from base package with annon
#function and using type 2 from e1071 library
kurtosis <- apply(mydata, 2, function(x) kurtosis(x, type = 2))
new_measure <- apply(mydata, 2, function(x) sd(x) / mad(x))
#create a new dataframe with the calculated kurtosis and new measure
base_mydata <- data.frame(kurtosis = kurtosis, new_measure = new_measure)
I do this aspect fine what I now have to do is use dplyr or purrr to do the above calculations and am not sure why this does not work. I simply get a vector or NaN values?
#Part 2
# Calculate kurtosis for each column
kurtosis_value <- mydata %>%
map_dbl(~ kurtosis(.x))
Any assistance/guidance apprecaited.
I do this aspect fine what I now have to do is use dplyr or purrr to do the above calculations and am not sure why this does not work. I simply get a vector or NaN values? I was expecting returned values with the kurtosis value of each column
#Part 2
# Calculate kurtosis for each column
kurtosis_value <- mydata %>%
map_dbl(~ kurtosis(.x))