README.md

summaryR

The goal of summaryR is to provide robust and consistent summaries. This is by enabling flexible definition of missing values and consistent return values, unlike base summary functions.

Installation

Currently the latest version of summaryR is available from github with:

install.packages("devtools")
library(devtools)
install_github("shadrackkibet/summaryR")

Loading summaryR package

library(summaryR)

Basic example code

Here is a basic example code using mean function.

x <- c(1,2,3,4,5,NA,NA,NA,6,7,8,9,NA,10)
summary_mean(x = x) # Return missing if anything is missing. 
#> [1] NA
summary_mean(x = x, na.rm = TRUE) # If anything is missing strip out the missing values and calculate the mean.
#> [1] 5.5
summary_mean(x = x, na.rm = TRUE, na_type = "n", na_max_n = 4) # If number of missing values is greater than 4 then return missing, otherwise return the mean.
#> [1] 5.5
summary_mean(x = x, na.rm = TRUE, na_type = "n_non_miss", na_min_n = 10) #If the number of non missing values is less or equal to 10 then return the mean, otherwise return missing.
#> [1] 5.5
summary_mean(x = x, na.rm = TRUE, na_type = "con", na_consecutive_n = 3) #Return summary if there are no more than 3 consecutive missing values, otherwise return missing
#> [1] 5.5

Other available functions include:



shadrackkibet/summaryR documentation built on Jan. 2, 2020, 12:54 a.m.