I need to calculate the kurtosis and skewness using the tapply function for every consecutive independent bins/window in the given dataset.
data <- data.frame(Time = c("09:01:01", "09:01:02", "09:01:03", "09:01:04", "09:01:05", "09:01:06", "09:01:07", "09:01:08",
"09:01:09", "09:01:10", "09:01:11", "09:01:12", "09:01:13", "09:01:14", "09:01:15", "09:01:16",
"09:01:17", "09:01:18", "09:01:19", "09:01:20"),
variable = c(36, 1, 46, 37, 29, 38, 11, 56, 45, 28, 6, 9, 51, 27, 38, 43, 16, 19, 33, 44))
data
Time variable
09:01:01 36
09:01:02 1
09:01:03 46
09:01:04 37
09:01:05 29
09:01:06 38
09:01:07 11
09:01:08 56
09:01:09 45
09:01:10 28
09:01:11 6
09:01:12 9
09:01:13 51
09:01:14 27
09:01:15 38
09:01:16 43
09:01:17 16
09:01:18 19
09:01:19 33
09:01:20 44
so i used the following code for calculating the skewness and kurtosis
x <- data$variable
a <- tapply(x, head(rep(seq(ceiling(length(x)/5)), each=5),length(x)), kurtosis)
b <- tapply(x, head(rep(seq(ceiling(length(x)/5)), each=5),length(x)), skewness)
Error in tapply(x, head(rep(seq(ceiling(length(x)/5)), each = 5), length(x)), : object 'kurtosis' not found
the expected result should be as follows: for mean
Time variable
09:01:01 29.8
09:01:06 35.6
09:01:11 26.2
09:01:16 31
the expected result for skewness should be as follows
Time variable
09:01:01 -1.55899
09:01:06 -0.49703
09:01:11 0.213318
09:01:16 -0.21706
thanks in advance