geometricSeq <- function(start, max, q) {
start * q^(seq(0, floor(log(max/start, q))))
}
kurtosis <- function(x) {
centralMomIV = 0
for (i in length(x)) {
centralMomIV = centralMomIV + (x[i] - mean(x))**4
}
((centralMomIV/length(x))/(sd(x)**4))
}
mode <- function(x) {
if (max(table(x)) < 2) {
'All values are unique'
} else {
as.numeric(names(table(x))[table(x)==max(table(x))])
}
}
unifiedRounding <- function(x) {
if (is.numeric(x)) {
if (x >= 0) {
round(x, 14)
} else {
round(x, 13)
}
} else {
'-'
}
}
skewness <- function(x) {
centralMomIII = 0
for (i in length(x)) {
centralMomIII = centralMomIII + (x[i] - mean(x))**3
}
((centralMomIII/length(x))/(sd(x)**3))
}
stats.summary <- function(x) {
cat('------------------------------------------\n')
cat(' Descriptive statistics\n')
cat('------------------------------------------\n\n')
cat(paste('Observations:', '\t\t', length(x), '\n'))
cat(paste('Mean:', '\t\t\t', unifiedRounding(mean(x)), '\n'))
cat(paste('Median:', '\t\t', unifiedRounding(median(x)), '\n'))
cat(paste('Mode:', '\t\t\t', unifiedRounding(mode(x)), '\n'))
cat(paste('Standard deviation:', '\t', unifiedRounding(sd(x)), '\n'))
cat(paste('Variance:', '\t\t', unifiedRounding(sd(x)**2), '\n'))
cat(paste('Skewness:', '\t\t', unifiedRounding(skewness(x)), '\n'))
cat(paste('Kurtosis:', '\t\t', unifiedRounding(kurtosis(x)), '\n'))
cat(paste('Range:', '\t\t\t', unifiedRounding(max(x)-min(x)), '\n\n'))
cat('------------------------------------------')
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.