Commit 78da98ad authored by Jalbert, Joe's avatar Jalbert, Joe
Browse files

New functions

parent 158e79d0
Package: JoeTools
Type: Package
Title: Loads Frequently Used Functions
Version: 0.1.0
Version: 0.1.1
Author: Joe Jalbert <joejalbert@gmail.com>
Maintainer: Joe Jalbert <joejalbert@gmail.com>
Description: Loads frequently used functions for data analysis and reporting.
......
# Generated by roxygen2: do not edit by hand
export(appendInteraction)
export(report)
export(se)
export(wbsave)
......
......@@ -85,6 +85,7 @@ report=function(df, Measures, Factor, paired=c("Yes", "No", "Try")){
reportpvaluecount=0
p=NULL
for(i in Measures){
reportpvaluecount=reportpvaluecount+1
form=paste0(i, "~",Factor)
......@@ -101,3 +102,36 @@ report=function(df, Measures, Factor, paired=c("Yes", "No", "Try")){
mutate(Signif=ifelse(p_value<.001, "***",ifelse(p_value<.01, "**",
ifelse(p_value<.05, "*", ifelse(p_value<.1, ".", "")))))
}
#' Appends Interactions to a \code{\link[JoeTools:report]{report()}} Output Dataframe
#'
#' @param report The report dataframe that is being appended
#' @param df The orginal dataframe used for the report
#' @param Measures A vector of string names for the dependant variable. Order must be the same as the repor
#' @param Factor A binary factor (as a string) which will be used for comparisons. Must be 1 (Treatment) or 0 (No_Treatment)
#' @param Interaction A factor column name (as a string) that will be used as an interacting independant variable.
#'
#' @return
#' @import tidyverse
#' @export
#'
#' @examples
appendInteraction=function(report,df, Measures,Factor,Interaction){
p=NULL
reportpvaluecount=0
for(i in Measures){
reportpvaluecount=reportpvaluecount+1
form=paste0(i, "~",Factor,"*",Interaction)
p[reportpvaluecount]=tryCatch(summary(aov(formula = as.formula(form), data=df))[[1]][["Pr(>F)"]][[3]], error=function(err) NA)
}
name=paste0(Interaction,"_pvalue")
name2=paste0(Interaction,"_Int")
output=report
output[[name]]=p
output=output%>%
mutate(NewP=ifelse(.data[[name]]<.001, "***",ifelse(.data[[name]]<.01, "**",
ifelse(.data[[name]]<.05, "*", ifelse(.data[[name]]<.1, ".", "")))))%>%
rename(!!name2:=NewP)
}
\ No newline at end of file
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/JoeToolFunctions.R
\name{appendInteraction}
\alias{appendInteraction}
\title{Appends Interactions to a \code{\link[JoeTools:report]{report()}} Output Dataframe}
\usage{
appendInteraction(report, df, Measures, Factor, Interaction)
}
\arguments{
\item{report}{The report dataframe that is being appended}
\item{df}{The orginal dataframe used for the report}
\item{Measures}{A vector of string names for the dependant variable. Order must be the same as the repor}
\item{Factor}{A binary factor (as a string) which will be used for comparisons. Must be 1 (Treatment) or 0 (No_Treatment)}
\item{Interaction}{A factor column name (as a string) that will be used as an interacting independant variable.}
}
\value{
}
\description{
Appends Interactions to a \code{\link[JoeTools:report]{report()}} Output Dataframe
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment