library(JoeNumainvilleTools) library(ggplot2) library(dplyr)
%xax% computes the transverse of a vector x multiplied by the inverse of matrix a multiplied by x
a <- matrix(c(3,8,7,1), nc = 2, nr = 2) x <- c(1,2) a %xax% x
xax works similarly, but in normal function notation
a <- matrix(c(3,8,7,1), nc = 2, nr = 2) x <- c(1,2) xax(a,x)
ggplot_Wrapper is a wrapper hat plots a ggplot scatter plot, with an optional color
ggplot_wrapper(food_coded, food_coded$GPA, food_coded$weight, as.factor(food_coded$Gender)) ggplot_wrapper(food_coded, food_coded$GPA, food_coded$weight)
mle calculates the maximum likelihood estimate of a vector for the gamma distribution
x <- c(1,2,3) mle(x)
opt is similar, but can take varying distributions and intervals
x <- c(1,2) logl <- function(alpha, x) {sum(dgamma(x, shape = alpha, log = TRUE))} interval <- mean(x) + c(-1, 1) * 3 * sd(x) opt(x, logl, interval)
myapply is like apply, but only works on margin 1 and 2
a <- matrix(1:9, nrow = 3, ncol = 3) myapply(a, 1, mean) myapply(a, 2, mean)
slice filters a column in some data so it meets the specified value
x <- c (1,2,2,3) y <- c (2,2,2,2) df <- data.frame(x,y) JoeNumainvilleTools::slice(df, df$x, 2) JoeNumainvilleTools::slice(df, df$y, 2)
standardize calculates (x - mean(x))/sd(x) for each column in a given matrix
a <- array(1:9, dim=c(3,3)) standardize(a)
summFunc gives a mean, variance, and standard deviation of a number vector in a list
x <- c(-3, 0, 3,1) mean <- sum(x) / length(x) var = sum((x - mean)^2)/length(x) sd = sqrt(var) summFunc(x)
weigtedSumm acts in a similar fashion, but also takes a vector p that adds up to 1 that gives each element in x a weight
x <- c(1,2,3) p <- c(.1,.2,.7) mean = sum(p * x) var = sum(((x - mean) ^ 2) * p) sd = sqrt(var) weightedSumm(x,p)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.