Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jalbert, Joe
JoeTools
Commits
78da98ad
Commit
78da98ad
authored
Feb 18, 2020
by
Jalbert, Joe
Browse files
New functions
parent
158e79d0
Changes
4
Hide whitespace changes
Inline
Side-by-side
DESCRIPTION
View file @
78da98ad
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.
...
...
NAMESPACE
View file @
78da98ad
# Generated by roxygen2: do not edit by hand
export(appendInteraction)
export(report)
export(se)
export(wbsave)
...
...
R/JoeToolFunctions.R
View file @
78da98ad
...
...
@@ -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
man/appendInteraction.Rd
0 → 100644
View file @
78da98ad
% 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
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment