descriptive_statistics: Generate Descriptive Statistics for a given dataset

Description Usage Arguments Value Examples

Description

Generates a variety of descriptive statistics for either the categorical variables or the numeric variables of a given dataset. Most notably for numeric variables; mean, median, variance, standard deviation, min, max, range, 1st quarile, 3rd quartile, inter quartile range, skeweness, kurtosis, Complete Observations, NA count and NA percentage. Note, all the descriptive statistics are calculated with any NA values removed. Most notably for categorical variables; number of levels, 1st and 2nd modes, count of the 1st and 2nd modes, percentage of the 1st and 2nd modes, amount of NA's and the percentage of NA's.

Usage

1
2
descriptive_statistics(dataset, type = c("numeric", "factor", "character"),
  file_name = NULL, directory = NULL)

Arguments

dataset

A dataset from which the descriptive statistics are derived.

type

A character object specfying the type of descriptive statistics to be derived. One of three; either "numeric", "factor", "character". Default is numeric

file_name

A character object indicating the file name when saving the data frame. The default is NULL. The name must include the .csv suffixs.

directory

A character object specifying the directory where the data frame is to be saved as a .csv file. .

Value

Outputs the descriptive statistics as a data frame.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Example Data
x1 <- rnorm(n = 60, mean = 50, sd = 10)
x2 <- rpois(n = 60, lambda = 50)
x3 <- sample(x = 1:10, size = 60, replace = TRUE)
x4 <- rep(x = c("yes", "no"), times = 30)
x5 <- rep(x = c("high", "medium", "low"), times = 20)
x6 <- sample(x = c("yes", "no"), size = 60, replace = TRUE)
# Save as a data frame
data <- as.data.frame(cbind(x1, x2, x3, x4, x5, x6))
# Derive descriptive statistics
descriptive_statistics(dataset = data, type = "numeric")
descriptive_statistics(dataset = data, type = "factor")

oislen/BuenaVista documentation built on May 16, 2019, 8:12 p.m.