Excel Statistical Summary Functions
These functions are designed to help users coming from an Excel background. Most functions replicate the behavior of Excel:
Names in most cases match Excel function names
Functionality replicates Excel
By default, missing values are ignored (same as in Excel)
SUM(x) AVERAGE(x) MEDIAN(x) MIN(x) MAX(x) COUNT(x) COUNT_UNIQUE(x) STDEV(x) VAR(x) COR(x, y) COV(x, y) FIRST(x) LAST(x) NTH(x, n = 1) CHANGE_FIRSTLAST(x) PCT_CHANGE_FIRSTLAST(x)
Summary Functions
All functions remove missing values (NA
). This is the same behavior as in Excel and most commonly what is desired.
Summary functions return a single value
Summary Functions - Return a single value from a vector
# Libraries library(tidyquant) library(timetk) library(tidyverse) library(forcats) # --- Basic Usage ---- SUM(1:10) PCT_CHANGE_FIRSTLAST(c(21, 24, 22, 25)) # --- Usage with tidyverse --- # Go from daily to monthly periodicity, # then calculate returns and growth of $1 USD FANG %>% mutate(symbol = as_factor(symbol)) %>% group_by(symbol) %>% # Summarization - Collapse from daily to FIRST value by month summarise_by_time( .date_var = date, .by = "month", adjusted = FIRST(adjusted) )
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.