diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..320850e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.swo +*.swp +docs diff --git a/.scripts/build_documentation.R b/.scripts/build_documentation.R new file mode 100644 index 0000000..7c355fb --- /dev/null +++ b/.scripts/build_documentation.R @@ -0,0 +1,3 @@ +library("devtools") + +devtools::document() diff --git a/.scripts/build_documentation_html.R b/.scripts/build_documentation_html.R new file mode 100644 index 0000000..62c8572 --- /dev/null +++ b/.scripts/build_documentation_html.R @@ -0,0 +1,4 @@ +library(pkgdown) + +pkgdown::build_site() + diff --git a/.scripts/build_package.R b/.scripts/build_package.R new file mode 100644 index 0000000..ed21d9a --- /dev/null +++ b/.scripts/build_package.R @@ -0,0 +1,3 @@ +library(devtools) + +devtools::build() diff --git a/.scripts/check_package.R b/.scripts/check_package.R new file mode 100644 index 0000000..4564b91 --- /dev/null +++ b/.scripts/check_package.R @@ -0,0 +1,2 @@ +library(devtools) +devtools::check() diff --git a/.scripts/install_package.R b/.scripts/install_package.R new file mode 100644 index 0000000..10f3ea4 --- /dev/null +++ b/.scripts/install_package.R @@ -0,0 +1,2 @@ +library(devtools) +devtools::install(upgrade=FALSE) diff --git a/.scripts/test_package.R b/.scripts/test_package.R new file mode 100644 index 0000000..fcc35a3 --- /dev/null +++ b/.scripts/test_package.R @@ -0,0 +1,2 @@ +library(devtools) +devtools::test() diff --git a/.scripts/test_package_cov.R b/.scripts/test_package_cov.R new file mode 100644 index 0000000..1767bb1 --- /dev/null +++ b/.scripts/test_package_cov.R @@ -0,0 +1,2 @@ +library(covr) +report() diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..3bd60d3 --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,24 @@ +Package: statstool +Title: An awesome R package with stats tolos +Version: 0.0.0 +Author: Alex Paxton +Maintainer: Alex Paxton +Description: What the package does. +Depends: R (>= 3.5) +Imports: dplyr, + pander, + xtable, + plyr +Suggests: testthat (>= 1.0.0), + knitr, + rmarkdown, + covr, + shiny, + DT, + roxygen2, + kableExtra +VignetteBuilder: knitr +License: MIT License + file LICENSE +Encoding: UTF-8 +LazyData: false +RoxygenNote: 6.1.1 diff --git a/license b/LICENSE similarity index 100% rename from license rename to LICENSE diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1e94153 --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +RSCRIPT ?= Rscript + + +all: doc-doxygen check build install test + +build: + $(RSCRIPT) .scripts/build_package.R + +install: doc-doxygen + $(RSCRIPT) .scripts/install_package.R + + +check: + $(RSCRIPT) .scripts/check_package.R + +doc-doxygen: + $(RSCRIPT) .scripts/build_documentation.R + +doc-html: install + $(RSCRIPT) .scripts/build_documentation_html.R + +doc: doc-html + +test: + $(RSCRIPT) .scripts/test_package.R diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..c6e78d1 --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,6 @@ +# Generated by roxygen2: do not edit by hand + +export(pander_anova) +export(pander_lm) +export(pander_lme_to_latex) +export(xtable_lme) diff --git a/pander_anova.r b/R/pander_anova.R similarity index 82% rename from pander_anova.r rename to R/pander_anova.R index 650e961..c5f94d4 100644 --- a/pander_anova.r +++ b/R/pander_anova.R @@ -1,21 +1,13 @@ +library(pander) +library(plyr) + +#' Create a cleaner ANOVA model output with pander. +#' +#' @param anova_model_name ANOVA model. Model whose output will be cleaned. +#' @return neat_output pander table. Cleaned ANOVA model output. +#' @export pander_anova = function(anova_model_name){ - #' Create a cleaner ANOVA model output with pander. - #' - #' Parameters - #' ---------- - #' anova_model_name : ANOVA model - #' Model whose output will be cleaned. - #' - #' Output - #' ------ - #' neat_output : pander table - #' Cleaned ANOVA model output. - - # load in pander - require(pander) - require(plyr) - # disable scientific notation options(scipen = 999) diff --git a/pander_lm.R b/R/pander_lm.R similarity index 79% rename from pander_lm.R rename to R/pander_lm.R index 921dae0..87bf8b4 100644 --- a/pander_lm.R +++ b/R/pander_lm.R @@ -1,20 +1,21 @@ +#' Create a cleaner lm model output with pander. +#' +#' Parameters +#' ---------- +#' lm_model_name : lm model +#' Model whose output will be cleaned. +#' +#' stats.caption : boolean, optional (default: FALSE) +#' Specify whether or not to provide the adjusted +#' R-squared and F-statistics in the table caption. +#' +#' Output +#' ------ +#' neat_output : table +#' Cleaned lm model output. +#' @export pander_lm = function(lm_model_name, stats.caption=FALSE){ - #' Create a cleaner lm model output with pander. - #' - #' Parameters - #' ---------- - #' lm_model_name : lm model - #' Model whose output will be cleaned. - #' - #' stats.caption : boolean, optional (default: FALSE) - #' Specify whether or not to provide the adjusted - #' R-squared and F-statistics in the table caption. - #' - #' Output - #' ------ - #' neat_output : table - #' Cleaned lm model output. # load in pander require(pander) diff --git a/pander_lme.R b/R/pander_lme.R similarity index 76% rename from pander_lme.R rename to R/pander_lme.R index 8ec18a2..e8267c1 100644 --- a/pander_lme.R +++ b/R/pander_lme.R @@ -1,23 +1,23 @@ +#' Create a cleaner lme4 model output with pander. +#' +#' Parameters +#' ---------- +#' lme_model_name : lme4 model +#' Model whose output will be cleaned. +#' +#' stats.caption : boolean, optional (default: FALSE) +#' Specify whether or not to provide the marginal +#' (i.e., fixed effects only) and conditional (i.e., +#' fixed and random effects) R-squared values in the +#' table's caption. +#' +#' Output +#' ------ +#' neat_output : pander table +#' Cleaned lme4 model output. +#' export pander_lme = function(lme_model_name, stats.caption=FALSE){ - #' Create a cleaner lme4 model output with pander. - #' - #' Parameters - #' ---------- - #' lme_model_name : lme4 model - #' Model whose output will be cleaned. - #' - #' stats.caption : boolean, optional (default: FALSE) - #' Specify whether or not to provide the marginal - #' (i.e., fixed effects only) and conditional (i.e., - #' fixed and random effects) R-squared values in the - #' table's caption. - #' - #' Output - #' ------ - #' neat_output : pander table - #' Cleaned lme4 model output. - # load in pander require(pander) diff --git a/pander_lme_to_latex.r b/R/pander_lme_to_latex.R similarity index 75% rename from pander_lme_to_latex.r rename to R/pander_lme_to_latex.R index f28adea..222522e 100644 --- a/pander_lme_to_latex.r +++ b/R/pander_lme_to_latex.R @@ -1,25 +1,25 @@ +#' Export an LMER summary table to a LaTex file. +#' +#' Note that this will retain the row index column, +#' which will be given a name`neat" in the table. +#' This will be need to be manually removed in the +#' final `.tex` file. +#' +#' Parameters +#' ---------- +#' lme_model_name : lme4 model +#' Model whose output will be cleaned. +#' +#' save_filename : str +#' File name for saved LaTex model. +#' +#' Output +#' ------ +#' neat_output : pander table +#' Cleaned lme4 model output. +#' @export pander_lme_to_latex = function(lme_model_name, save_filename){ - #' Export an LMER summary table to a LaTex file. - #' - #' Note that this will retain the row index column, - #' which will be given a name`neat" in the table. - #' This will be need to be manually removed in the - #' final `.tex` file. - #' - #' Parameters - #' ---------- - #' lme_model_name : lme4 model - #' Model whose output will be cleaned. - #' - #' save_filename : str - #' File name for saved LaTex model. - #' - #' Output - #' ------ - #' neat_output : pander table - #' Cleaned lme4 model output. - # load in pander require(pander) require(Hmisc) diff --git a/xtable_lme.r b/R/xtable_lme.R similarity index 81% rename from xtable_lme.r rename to R/xtable_lme.R index 8b86a77..c55c932 100644 --- a/xtable_lme.r +++ b/R/xtable_lme.R @@ -1,18 +1,17 @@ +#' Create a cleaner lme4 model output for printing with xtable. +#' +#' Parameters +#' ---------- +#' lme_model_name : lme4 model +#' Model whose output will be cleaned. +#' +#' Output +#' ------ +#' neat_output : table +#' Cleaned lme4 model output. +#' @export xtable_lme = function(lme_model_name){ - #' Create a cleaner lme4 model output for - #' printing with xtable. - #' - #' Parameters - #' ---------- - #' lme_model_name : lme4 model - #' Model whose output will be cleaned. - #' - #' Output - #' ------ - #' neat_output : table - #' Cleaned lme4 model output. - # load in pander library(pander) library(dplyr) diff --git a/doc/TODO b/doc/TODO deleted file mode 100644 index 4ba08ee..0000000 --- a/doc/TODO +++ /dev/null @@ -1,3 +0,0 @@ -# TODO list - -- Alex, you should really package this code! diff --git a/man/README b/man/README new file mode 100644 index 0000000..0f4663e --- /dev/null +++ b/man/README @@ -0,0 +1 @@ +This folder is automatically generated. DO NOT EDIT MANUALLY. diff --git a/man/pander_anova.Rd b/man/pander_anova.Rd new file mode 100644 index 0000000..7ce6f84 --- /dev/null +++ b/man/pander_anova.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/pander_anova.R +\name{pander_anova} +\alias{pander_anova} +\title{Create a cleaner ANOVA model output with pander.} +\usage{ +pander_anova(anova_model_name) +} +\arguments{ +\item{anova_model_name}{ANOVA model. Model whose output will be cleaned.} +} +\value{ +neat_output pander table. Cleaned ANOVA model output. +} +\description{ +Create a cleaner ANOVA model output with pander. +} diff --git a/man/pander_lm.Rd b/man/pander_lm.Rd new file mode 100644 index 0000000..bd12f59 --- /dev/null +++ b/man/pander_lm.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/pander_lm.R +\name{pander_lm} +\alias{pander_lm} +\title{Create a cleaner lm model output with pander.} +\usage{ +pander_lm(lm_model_name, stats.caption = FALSE) +} +\description{ +Parameters + ---------- + lm_model_name : lm model + Model whose output will be cleaned. +} +\details{ +stats.caption : boolean, optional (default: FALSE) + Specify whether or not to provide the adjusted + R-squared and F-statistics in the table caption. + +Output + ------ + neat_output : table + Cleaned lm model output. +} diff --git a/man/pander_lme.Rd b/man/pander_lme.Rd new file mode 100644 index 0000000..8c964a6 --- /dev/null +++ b/man/pander_lme.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/pander_lme.R +\name{pander_lme} +\alias{pander_lme} +\title{Create a cleaner lme4 model output with pander.} +\usage{ +pander_lme(lme_model_name, stats.caption = FALSE) +} +\description{ +Parameters + ---------- + lme_model_name : lme4 model + Model whose output will be cleaned. +} +\details{ +stats.caption : boolean, optional (default: FALSE) + Specify whether or not to provide the marginal + (i.e., fixed effects only) and conditional (i.e., + fixed and random effects) R-squared values in the + table's caption. + +Output + ------ + neat_output : pander table + Cleaned lme4 model output. +export +} diff --git a/man/pander_lme_to_latex.Rd b/man/pander_lme_to_latex.Rd new file mode 100644 index 0000000..735b148 --- /dev/null +++ b/man/pander_lme_to_latex.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/pander_lme_to_latex.R +\name{pander_lme_to_latex} +\alias{pander_lme_to_latex} +\title{Export an LMER summary table to a LaTex file.} +\usage{ +pander_lme_to_latex(lme_model_name, save_filename) +} +\description{ +Note that this will retain the row index column, + which will be given a name`neat" in the table. + This will be need to be manually removed in the + final `.tex` file. +} +\details{ +Parameters + ---------- + lme_model_name : lme4 model + Model whose output will be cleaned. + +save_filename : str + File name for saved LaTex model. + +Output + ------ + neat_output : pander table + Cleaned lme4 model output. +} diff --git a/man/xtable_lme.Rd b/man/xtable_lme.Rd new file mode 100644 index 0000000..4199fd3 --- /dev/null +++ b/man/xtable_lme.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/xtable_lme.R +\name{xtable_lme} +\alias{xtable_lme} +\title{Create a cleaner lme4 model output for printing with xtable.} +\usage{ +xtable_lme(lme_model_name) +} +\description{ +Parameters + ---------- + lme_model_name : lme4 model + Model whose output will be cleaned. +} +\details{ +Output + ------ + neat_output : table + Cleaned lme4 model output. +} diff --git a/vignettes/tutorial.Rmd b/vignettes/tutorial.Rmd new file mode 100644 index 0000000..a72fe4f --- /dev/null +++ b/vignettes/tutorial.Rmd @@ -0,0 +1,18 @@ +--- +title: "Installation" +output: rmarkdown::html_vignette +vignette: > + %\VignetteEngine{knitr::knitr} + %\VignetteIndexEntry{Installation} + %\usepackage[UTF-8]{inputenc} +--- + +The package moanin was developped to provide a simple and efficient workflow +for time-course gene expression data. To use this package, install it with + +```{r eval=FALSE} +# install devtools +install.packages("devtools") +# use devtools to install the package +devtools::install_github("NelleV/stats-tool", branch="r_package") +```