nievergeltlab
3/1/2017 - 6:21 PM

Quick access functions for R

Quick access functions for R

#Summary shortcut
s <- function(...)
	{
		summary(...)
	}


#Get a linear model summary quickly
slm <- function (...)
	{
		summary(lm(...))
	}
	
#Get a logistic model summary quickly
sglm <- function (...)
	{
		summary(glm(...))
	}
	
#Get a ZINB model summary quickly
szinb <- function (...)
	{
		summary(zeroinfl(...,dist="negbin"))
	}
	
#Read csv in the way I always do
rcsv <- function(...)
	{
		read.csv(..., header=T, stringsAsFactors=FALSE,na.strings=c("NA", "#N/A"))
	}
	
#This is a maximum function designed to handle NA
#sets by changing -Inf to NA (by default its -inf since the smallest number greater than nothing is -Inf
goodMax<- function (x)
{
	maxOut <- max(x, na.rm=T)
	if (maxOut == -Inf)
	maxOut <- NA
	
	return(maxOut)
}