# NOT RUN {
library(metan)
#===============================================================#
# Example 1: main statistics (coefficient of variation, maximum,#
# mean, median, minimum, sample standard deviation, standard #
# error and confidence interval of the mean) for all numeric #
# variables in data #
#===============================================================#
desc_stat(data_ge2)
#===============================================================#
#Example 2: robust statistics using a numeric vector as input #
# data
#===============================================================#
vect <- data_ge2$TKW
desc_stat(vect, stats = "robust")
#===============================================================#
# Example 3: Select specific statistics. In this example, NAs #
# are removed before analysis with a warning message #
#===============================================================#
desc_stat(c(12, 13, 19, 21, 8, NA, 23, NA),
stats = c('mean, se, cv, n, n.valid'),
na.rm = TRUE)
#===============================================================#
# Example 4: Select specific variables and compute statistics by#
# levels of a factor variable (GEN) #
#===============================================================#
stats <-
desc_stat(data_ge2,
EP, EL, EH, ED, PH, CD,
by = GEN)
stats
# To get a 'wide' format with the maximum values for all variables
desc_wider(stats, max)
#===============================================================#
# Example 5: Compute all statistics for all numeric variables #
# by two or more factors. Note that group_by() was used to pass #
# grouped data to the function desc_stat() #
#===============================================================#
data_ge2 %>%
group_by(ENV, GEN) %>%
desc_stat()
# }
Run the code above in your browser using DataLab