├── .Rbuildignore ├── .gitignore ├── DESCRIPTION ├── NAMESPACE ├── R ├── create_appendix.R ├── create_memo.R ├── create_project.R ├── create_rproj.R ├── dl_csl.R ├── render_appendix.R ├── render_memo.R └── render_ms.R ├── README.Rmd ├── README.md ├── _pkgdown.yml ├── docs ├── 404.html ├── authors.html ├── bootstrap-toc.css ├── bootstrap-toc.js ├── docsearch.css ├── docsearch.js ├── extra.css ├── index.html ├── link.svg ├── pkgdown.css ├── pkgdown.js ├── pkgdown.yml ├── reference │ ├── Rplot001.png │ ├── create_appendix.html │ ├── create_memo.html │ ├── create_project.html │ ├── create_rproj.html │ ├── dl_csl.html │ ├── index.html │ ├── render_appendix.html │ ├── render_memo.html │ └── render_ms.html └── sitemap.xml ├── inst ├── README │ ├── steveproj-1.png │ ├── steveproj-2.png │ └── steveproj-3.png ├── other_docs │ ├── appendix.Rmd │ └── memo.Rmd ├── rproj │ └── rename-this.Rproj ├── rstudio │ └── templates │ │ └── project │ │ ├── create_project.dcf │ │ └── icon-44.png └── skeleton │ ├── .gitattributes │ ├── Makefile │ ├── R │ ├── 1-prep.R │ ├── 2-analysis.R │ ├── 3-qi.R │ ├── _helpers.R │ └── _render.R │ ├── README.md │ ├── _config.yaml │ ├── _output.yaml │ ├── _targets.R │ ├── inst │ └── refs.bib │ └── ms.Rmd ├── man ├── create_appendix.Rd ├── create_memo.Rd ├── create_project.Rd ├── create_rproj.Rd ├── dl_csl.Rd ├── render_appendix.Rd ├── render_memo.Rd └── render_ms.Rd ├── pkgdown └── extra.css ├── steveproj.Rproj └── tests ├── testthat.R └── testthat └── test-create_project.R /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^README\.Rmd$ 4 | ^example$ 5 | ^inst/README$ 6 | ^_pkgdown\.yml$ 7 | ^docs$ 8 | ^pkgdown$ 9 | ^_dross$ 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | 6 | !.gitignore 7 | example 8 | 9 | # This is where I hide junk 10 | _dross 11 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: steveproj 2 | Type: Package 3 | Title: Steve's Academic R Projects 4 | Version: 0.1.9 5 | Author: Steven V. Miller 6 | Maintainer: Steven V. Miller 7 | Description: This is a one-function suite and skeleton project directory to help you 8 | start and manage R projects with an eye toward producing an academic project (to 9 | culminate in an academic paper). This package will lean on "R Markdown" and "Make". 10 | BugReports: https://github.com/svmiller/steveproj/issues 11 | URL: http://svmiller.com/steveproj/ 12 | License: GPL-2 13 | Encoding: UTF-8 14 | LazyData: true 15 | Imports: 16 | bib2df, 17 | bookdown, 18 | dplyr, 19 | httr, 20 | huxtable, 21 | kableExtra, 22 | magrittr, 23 | modelr, 24 | modelsummary, 25 | readr, 26 | rmarkdown, 27 | stevetemplates (>= 0.7.0), 28 | stevemisc (>= 1.0.0), 29 | stringr, 30 | yaml, 31 | ymlthis 32 | Suggests: 33 | testthat (>= 3.0.0) 34 | RoxygenNote: 7.1.2 35 | Roxygen: list(markdown = TRUE) 36 | Config/testthat/edition: 3 37 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | exportPattern("^[[:alpha:]]+") 2 | 3 | # This is for downloading CSLs 4 | importFrom(httr, "GET", "write_disk", "http_error", "status_code") 5 | importFrom(tools, "file_ext") 6 | 7 | # This is for rendering stuff 8 | 9 | importFrom(rmarkdown, "pandoc_available", "render") 10 | importFrom(bookdown, "pdf_document2", "word_document2", "html_document2") 11 | importFrom(stevetemplates, "templ_html_article", "templ_word", "templ_article2", "templ_cover_letter") 12 | -------------------------------------------------------------------------------- /R/create_appendix.R: -------------------------------------------------------------------------------- 1 | #' Create an Appendix File for Your Academic Project 2 | #' 3 | #' @description \code{create_appendix()} creates an R Markdown for an appendix 4 | #' to go with your academic project. 5 | #' 6 | #' @param path a path in which to place the appendix file. Defaults to current 7 | #' working directory in the absence of a user-specified argument. User-supplied 8 | #' arguments here should be understood as subdirectories relative to current 9 | #' working directory. Assume that the current working directory is something 10 | #' like `/home/steve/`, then specifying a path of "Documents" in this argument 11 | #' would create the memo file in `/home/steve/Documents`. Just be mindful about 12 | #' your setup if you experiment with this argument. 13 | #' 14 | #' @return \code{create_appendix()} creates a `appendix.Rmd` file in the path 15 | #' requested by user. Users can create an appendix at any time during the 16 | #' submission timeline of the academic project, but I often---but not 17 | #' always---create them at the revise-and-resubmit phase. That would explain 18 | #' why it's not a default file. 19 | #' 20 | #' @examples 21 | #' 22 | #' \dontrun{ 23 | #' # Creates a `appendix.Rmd` file in working directory 24 | #' create_appendix() 25 | #' 26 | #' # Creates a `appendix.Rmd` in subdirectory of working directory 27 | #' 28 | #' create_appendix("subdirectory") 29 | #' } 30 | #' 31 | #' @export 32 | 33 | create_appendix <- function(path) { 34 | 35 | if (missing(path)) { 36 | current_dir <- getwd() 37 | } else { 38 | current_dir <- paste0(getwd(), "/", path) 39 | } 40 | 41 | if (file.exists(paste0(current_dir,"/appendix.Rmd"))) { 42 | stop("appendix.Rmd exists in the path. If you want a new one, delete this file, move it, or rename it.") 43 | } 44 | 45 | memo_file = system.file('other_docs', "appendix.Rmd", package='steveproj') 46 | file.copy(memo_file, current_dir) 47 | TRUE 48 | } 49 | -------------------------------------------------------------------------------- /R/create_memo.R: -------------------------------------------------------------------------------- 1 | #' Create a Memo File for Your Academic Project 2 | #' 3 | #' @description \code{create_memo()} creates an R Markdown for a memo to go 4 | #' with your academic project. 5 | #' 6 | #' @param path a path in which to place the memo file. Defaults to current 7 | #' working directory in the absence of a user-specified argument. User-supplied 8 | #' arguments here should be understood as subdirectories relative to current 9 | #' working directory. Assume that the current working directory is something 10 | #' like `/home/steve/`, then specifying a path of "Documents" in this argument 11 | #' would create the memo file in `/home/steve/Documents`. Just be mindful about 12 | #' your setup if you experiment with this argument. 13 | #' 14 | #' @return \code{create_memo()} creates a `memo.Rmd` file in the path 15 | #' requested by user. Users can create a memo at any time during the submission 16 | #' timeline of the academic project, but I think of these documents as 17 | #' typically something a user writes when offered an opportunity to revise and 18 | #' resubmit a manuscript. That would explain why the skeleton file is 19 | #' structured the way it is. 20 | #' 21 | #' @examples 22 | #' 23 | #' \dontrun{ 24 | #' # Creates a `memo.Rmd` file in working directory 25 | #' create_memo() 26 | #' 27 | #' # Creates a `memo.Rmd` in subdirectory of working directory 28 | #' 29 | #' create_memo("subdirectory") 30 | #' } 31 | #' 32 | #' @export 33 | 34 | create_memo <- function(path) { 35 | 36 | if (missing(path)) { 37 | current_dir <- getwd() 38 | } else { 39 | current_dir <- paste0(getwd(), "/", path) 40 | } 41 | 42 | if (file.exists(paste0(current_dir,"/memo.Rmd"))) { 43 | stop("memo.Rmd exists in the path. If you want a new one, delete this file, move it, or rename it.") 44 | } 45 | 46 | memo_file = system.file('other_docs', "memo.Rmd", package='steveproj') 47 | file.copy(memo_file, current_dir) 48 | TRUE 49 | } 50 | -------------------------------------------------------------------------------- /R/create_project.R: -------------------------------------------------------------------------------- 1 | #' Create an Academic Project/Paper Project 2 | #' 3 | #' @description \code{create_project()} provides a convenient function for creating 4 | #' a new academic/paper project. 5 | #' 6 | #' 7 | #' @param path the directory name for the project (e.g. "my-project", "dissertation", or whatever) 8 | #' @param ... optional stuff, but you can ignore this 9 | #' 10 | #' @return \code{create_project()} creates a directory named with whatever is supplied in the \code{path} variable. This 11 | #' directory will appear in the current working directory if it is executed in the command line. The contents of that 12 | #' directory will include a skeleton project to get the user started. The user can (and must) ultimately make it their own. 13 | #' 14 | #' @examples 15 | #' 16 | #' \dontrun{ 17 | #' create_project("example") 18 | #' create_project("dissertation") 19 | #' } 20 | #' 21 | #' @export 22 | create_project <- function(path, ...) { 23 | 24 | # ensure directory exists 25 | dir.create(path, recursive = TRUE, showWarnings = FALSE) 26 | 27 | # copy 'resources' folder to path 28 | resources = system.file('skeleton', package='steveproj') 29 | # 30 | files = list.files(resources, recursive = TRUE, include.dirs = TRUE) 31 | # 32 | source = file.path(resources, files) 33 | target = file.path(path, files) 34 | # file.copy(source, target, recursive=TRUE) 35 | dir.create(paste0(path,"/src")) 36 | dir.create(paste0(path,"/R")) 37 | dir.create(paste0(path,"/doc")) 38 | dir.create(paste0(path,"/data")) 39 | dir.create(paste0(path,"/inst")) 40 | #file.copy(resources, path) 41 | file.copy(source, target) 42 | TRUE 43 | } 44 | 45 | # Callback is at: inst/rstudio/templates/project/create_project.dcf 46 | -------------------------------------------------------------------------------- /R/create_rproj.R: -------------------------------------------------------------------------------- 1 | #' Create an R Project File in your Academic Project 2 | #' 3 | #' @description \code{create_rproj()} finishes by way of command line what Rstudio will do 4 | #' naturally. It will add a simple \code{.Rproj} file to your directory. 5 | #' 6 | #' 7 | #' @param path the directory name for the project (e.g. "my-project", "dissertation", or whatever) 8 | #' @param ... optional stuff, but you can ignore this 9 | #' 10 | #' @return \code{create_rproj()} creates an \code{.Rproj} file in your directory. It should be run 11 | #' in the command line \emph{after} running \code{create_project{}} in the command line. You will NOT 12 | #' need to do this if you elect to use Rstudio's interface for the creation of a project. Rstudio 13 | #' will do that for you automatically. 14 | #' 15 | #' @examples 16 | #' 17 | #' \dontrun{ 18 | #' create_project("example") # creates new directory 19 | #' create_rproj("example") # creates new \code{.Rproj} file in that directory 20 | #' } 21 | #' 22 | #' @export 23 | 24 | create_rproj <- function(path, ...) { 25 | resources = system.file('rproj', package='steveproj') 26 | files = list.files(resources, recursive = TRUE, include.dirs = TRUE) 27 | source = file.path(resources, files) 28 | target = file.path(path, files) 29 | #file.copy(resources, path) 30 | file.copy(source, target) 31 | file.rename(paste0(target), paste0(path,"/",path,".Rproj")) 32 | TRUE 33 | } 34 | -------------------------------------------------------------------------------- /R/dl_csl.R: -------------------------------------------------------------------------------- 1 | #' Download Citation Style Language (CSL) File from Github 2 | #' 3 | #' @description \code{dl_csl()} will download a requested citation style language (CSL) file from the 4 | #' Github repository of CSL files. 5 | #' 6 | #' @details \code{dl_csl()} assumes an active internet connection. The function also builds in a few implicit defaults. 7 | #' If a file matching the requested CSL exists, the function does nothing. If the requested CSL does not have a ".csl" 8 | #' extension, the function assumes you forgot it and adds it for you. By default, the function downloads the CSL file 9 | #' and sticks it in your "inst" folder in the working directory. You can change this if you'd like with the \code{dir} 10 | #' argument. If the directory does not exist, the function creates it for you. If you'd like the CSL file in the current 11 | #' directory, set the \code{dir} argument to be \code{NULL}. The Github repository of CSL files is available here: 12 | #' \url{https://github.com/citation-style-language/styles}. 13 | #' 14 | #' 15 | #' @param csl a valid CSL file on the GIthub repository of CSL files, with or without file extension 16 | #' @param dir the subdirectory in the working directory in which you want the CSL file, defaults to "inst". A user who wants 17 | #' the CSL file in their current working directory should set this to be \code{NULL}. 18 | #' 19 | #' @return \code{dl_csl()} takes a requested CSL file (from the Github repository) and an optional subdirectory, 20 | #' downloads the CSL file, and sticks it in the requested directory. 21 | #' 22 | #' @examples 23 | #' 24 | #' \dontrun{ 25 | #' dl_csl("american-political-science-association.csl") 26 | #' # ^ Works, has extension too 27 | #' dl_csl("journal-of-peace-research") 28 | #' # ^ Will also work, but message you that it assumes you forgot ".csl" 29 | #' } 30 | #' 31 | #' @export 32 | dl_csl <- function(csl, dir="inst") { 33 | 34 | if (!is.null(dir) && !dir.exists(dir)) { 35 | dir.create(dir) 36 | } 37 | 38 | if (tools::file_ext(csl)!="csl") { 39 | message("I'm going to assume you forgot to add the .csl extension. I'll add that for you.") 40 | csl <- paste0(csl, ".csl") 41 | } 42 | 43 | if (!is.null(dir) && !file.exists(paste0(dir,"/",csl))) { 44 | cslurl <- file.path("https://raw.githubusercontent.com/citation-style-language/styles/master", csl) 45 | message(paste("Downloading CSL from", cslurl)) 46 | cslresp <- GET(cslurl, write_disk(csl)) 47 | 48 | if(http_error(cslresp)) { 49 | file.remove(csl) 50 | stop(paste("Could not download CSL.", "Code:", status_code(cslresp))) 51 | } 52 | 53 | file.copy(csl, dir) 54 | file.remove(csl) 55 | 56 | } 57 | 58 | if (is.null(dir) && !file.exists(csl)) { 59 | 60 | cslurl <- file.path("https://raw.githubusercontent.com/citation-style-language/styles/master", csl) 61 | message(paste("Downloading CSL from", cslurl)) 62 | cslresp <- GET(cslurl, write_disk(csl)) 63 | 64 | if(http_error(cslresp)) { 65 | file.remove(csl) 66 | stop(paste("Could not download CSL.", "Code:", status_code(cslresp))) 67 | } 68 | 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /R/render_appendix.R: -------------------------------------------------------------------------------- 1 | #' Render Your R Markdown Appendix to Various Outputs 2 | #' 3 | #' @description `render_appendix()` takes various arguments, most effectively built 4 | #' into the function, and renders your R Markdown manuscript to various outputs 5 | #' supported by \pkg{stevetemplates}. 6 | #' 7 | #' 8 | #' @param file the name of the R Markdown file containing that is your 9 | #' appendix. Defaults to "appendix.Rmd". 10 | #' @param output_dir the output directory to contain the formatted manuscript. 11 | #' Defaults to "doc". Optimally, this is a subdirectory of the directory 12 | #' containing the manuscript. A user who wants the formatted manuscript 13 | #' to be in the same directory as the R Markdown file should specify 14 | #' `output_dir = NULL` here. 15 | #' @param outputs the various formatted manuscript types the user wants, 16 | #' supplied as a character vector. Must be one or more of "pdf", "pdf-anon", 17 | #' "word", and/or "html". No other formats are supported right now. Defaults 18 | #' are "pdf" and "pdf-anon". 19 | #' @param parameters optional parameters, specified as a character, based on 20 | #' what's in your R Markdown file, passed as `params` in the `render()` 21 | #' function in R Markdown. If no parameters are specified here, the 22 | #' function defaults these parameters to 23 | #' `anonymous=TRUE, doublespacing=TRUE`, 24 | #' which is then wrapped in a list to be passed to the `params` 25 | #' argument in `render()`. Do note this primarily concerns the anonymous 26 | #' manuscript type. These are somewhat advanced-level arguments, so the user 27 | #' should be careful what they do here and should have a firm idea what 28 | #' they are doing here. 29 | #' @param latex_engine the LaTeX engine the user may want to use. 30 | #' Defaults to `"xelatex"`. You can overwrite this if you would like, but 31 | #' why would you? 32 | #' @param dev the graphics device for LaTeX PDFs. Defaults to `"cairo_pdf"`. 33 | #' You can overwrite this, but why would you? 34 | #' 35 | #' @return `render_ms()` takes various arguments, most effectively built 36 | #' into the function, and renders your R Markdown manuscript to various outputs 37 | #' supported by \pkg{stevetemplates}. 38 | #' 39 | #' @examples 40 | #' 41 | #' \dontrun{ 42 | #' render_appendix() 43 | #' } 44 | #' 45 | #' @export 46 | #' 47 | 48 | render_appendix <- function(file = "appendix.Rmd", output_dir = "doc", 49 | outputs = c("pdf", "pdf-anon"), 50 | parameters, latex_engine = "xelatex", dev = "cairo_pdf") { 51 | 52 | if (!all(outputs %in% c("pdf", "pdf-anon", "word", "html"))) { 53 | stop("Invalid outputs are specified. Valid entries here are limited to 'pdf', 'pdf-anon', 'word', and 'html'") 54 | } 55 | 56 | if(pandoc_available() == FALSE) { 57 | stop("R can't find a version of pandoc to use. RStudio has a version of pandoc built into it, but using the original command line interface may lead to an issue like this. Solving this will depend on your particular set up. This solution on Stack Overflow may point to a potential workaround, certainly if you have RStudio installed: https://stackoverflow.com/questions/35624025/pandoc-from-rsudio-server-not-recognized-when-running-script-via-cron") 58 | } 59 | 60 | 61 | 62 | if(missing(parameters)) { 63 | the_params <- eval(parse(text = paste0("list(anonymous=TRUE, doublespacing=TRUE)"))) 64 | } else { 65 | the_params <- eval(parse(text = paste0("list(", parameters," )"))) 66 | } 67 | 68 | 69 | file_split <- unlist(strsplit(file,"[.]")) 70 | file_name <- file_split[1] 71 | 72 | if("pdf" %in% outputs) { 73 | 74 | 75 | if(is.null(output_dir)) { 76 | 77 | file_location <- paste0(file_name,".pdf") 78 | } else { # assuming an output directory is specified 79 | 80 | file_location <- paste0(output_dir,"/",file_name,".pdf") 81 | 82 | 83 | } 84 | 85 | render(input = file, 86 | output_file = file_location, 87 | pdf_document2(template = templ_article2(), 88 | latex_engine = "xelatex", dev="cairo_pdf", toc = FALSE, 89 | number_sections = FALSE)) 90 | 91 | } 92 | 93 | if("pdf-anon" %in% outputs) { 94 | 95 | if(is.null(output_dir)) { 96 | 97 | file_location <- paste0(file_name,".pdf") 98 | } else { # assuming an output directory is specified 99 | 100 | file_location <- paste0(output_dir,"/",file_name,"-anon.pdf") 101 | 102 | 103 | } 104 | 105 | render(input = file, 106 | output_file = file_location, 107 | params=the_params, 108 | pdf_document2(template = templ_article2(), 109 | latex_engine = "xelatex", dev= "cairo_pdf", toc = FALSE, 110 | number_sections = FALSE)) 111 | 112 | } 113 | 114 | 115 | if("word" %in% outputs) { 116 | 117 | 118 | if(is.null(output_dir)) { 119 | 120 | file_location <- paste0(file_name,".docx") 121 | } else { # assuming an output directory is specified 122 | 123 | file_location <- paste0(output_dir,"/",file_name,".docx") 124 | 125 | 126 | } 127 | 128 | render(input = file, 129 | output_file = file_location, 130 | word_document2(reference_docx = templ_word(), 131 | toc = FALSE, number_sections = FALSE)) 132 | } 133 | 134 | if ("html" %in% outputs) { 135 | 136 | if(is.null(output_dir)) { 137 | 138 | file_location <- paste0(file_name,".html") 139 | } else { # assuming an output directory is specified 140 | 141 | file_location <- paste0(output_dir,"/",file_name,".html") 142 | 143 | 144 | } 145 | 146 | render(input = file, 147 | output_file = file_location, 148 | html_document2(template = templ_html_article(), 149 | toc = FALSE, number_sections = FALSE)) 150 | 151 | } 152 | 153 | } 154 | 155 | -------------------------------------------------------------------------------- /R/render_memo.R: -------------------------------------------------------------------------------- 1 | #' Render Your R Markdown Memo to Various Outputs 2 | #' 3 | #' @description `render_memo()` takes various arguments, most effectively built 4 | #' into the function, and renders your R Markdown memo to various outputs 5 | #' supported by \pkg{stevetemplates}. 6 | #' 7 | #' 8 | #' @param file the name of the R Markdown file containing that is your 9 | #' memo Defaults to "memo.Rmd". 10 | #' @param output_dir the output directory to contain the formatted manuscript. 11 | #' Defaults to "doc". Optimally, this is a subdirectory of the directory 12 | #' containing the manuscript. A user who wants the formatted manuscript 13 | #' to be in the same directory as the R Markdown file should specify 14 | #' `output_dir = NULL` here. 15 | #' @param outputs the various formatted manuscript types the user wants, 16 | #' supplied as a character vector. Must be one or more of "pdf" and/or "word". 17 | #' No other formats are supported right now. 18 | #' @param latex_engine the LaTeX engine the user may want to use. 19 | #' Defaults to `"xelatex"`. You can overwrite this if you would like, but 20 | #' why would you? 21 | #' @param dev the graphics device for LaTeX PDFs. Defaults to `"cairo_pdf"`. 22 | #' You can overwrite this, but why would you? 23 | #' 24 | #' @return `render_memo()` takes various arguments, most effectively built 25 | #' into the function, and renders your R Markdown memo to various outputs 26 | #' supported by \pkg{stevetemplates}. 27 | #' 28 | #' @examples 29 | #' 30 | #' \dontrun{ 31 | #' render_memo() 32 | #' } 33 | #' 34 | #' @export 35 | #' 36 | 37 | render_memo <- function(file = "memo.Rmd", output_dir = "doc", 38 | outputs = c("pdf", "word"), 39 | latex_engine = "xelatex", dev = "cairo_pdf") { 40 | 41 | if (!all(outputs %in% c("pdf", "word"))) { 42 | stop("Invalid outputs are specified. Valid entries here are limited to 'pdf', 'pdf-anon', 'word', and 'html'") 43 | } 44 | 45 | if(pandoc_available() == FALSE) { 46 | stop("R can't find a version of pandoc to use. RStudio has a version of pandoc built into it, but using the original command line interface may lead to an issue like this. Solving this will depend on your particular set up. This solution on Stack Overflow may point to a potential workaround, certainly if you have RStudio installed: https://stackoverflow.com/questions/35624025/pandoc-from-rsudio-server-not-recognized-when-running-script-via-cron") 47 | } 48 | 49 | 50 | file_split <- unlist(strsplit(file,"[.]")) 51 | file_name <- file_split[1] 52 | 53 | if("pdf" %in% outputs) { 54 | 55 | 56 | if(is.null(output_dir)) { 57 | 58 | file_location <- paste0(file_name,".pdf") 59 | } else { # assuming an output directory is specified 60 | 61 | file_location <- paste0(output_dir,"/",file_name,".pdf") 62 | 63 | 64 | } 65 | 66 | render(input = file, 67 | output_file = file_location, 68 | pdf_document2(template = templ_cover_letter(), 69 | latex_engine = "xelatex", dev="cairo_pdf", toc = FALSE, 70 | number_sections = FALSE)) 71 | 72 | } 73 | 74 | 75 | if("word" %in% outputs) { 76 | 77 | 78 | if(is.null(output_dir)) { 79 | 80 | file_location <- paste0(file_name,".docx") 81 | } else { # assuming an output directory is specified 82 | 83 | file_location <- paste0(output_dir,"/",file_name,".docx") 84 | 85 | 86 | } 87 | 88 | render(input = file, 89 | output_file = file_location, 90 | word_document2(reference_docx = templ_word(), 91 | toc = FALSE, number_sections = FALSE)) 92 | } 93 | 94 | 95 | } 96 | 97 | -------------------------------------------------------------------------------- /R/render_ms.R: -------------------------------------------------------------------------------- 1 | #' Render Your R Markdown Manuscript to Various Outputs 2 | #' 3 | #' @description `render_ms()` takes various arguments, most effectively built 4 | #' into the function, and renders your R Markdown manuscript to various outputs 5 | #' supported by \pkg{stevetemplates}. 6 | #' 7 | #' 8 | #' @param file the name of the R Markdown file containing that is your 9 | #' manuscript. Defaults to "ms.Rmd". 10 | #' @param output_dir the output directory to contain the formatted manuscript. 11 | #' Defaults to "doc". Optimally, this is a subdirectory of the directory 12 | #' containing the manuscript. A user who wants the formatted manuscript 13 | #' to be in the same directory as the R Markdown file should specify 14 | #' `output_dir = NULL` here. 15 | #' @param outputs the various formatted manuscript types the user wants, 16 | #' supplied as a character vector. Must be one or more of "pdf", "pdf-anon", 17 | #' "word", and/or "html". No other formats are supported right now. 18 | #' @param parameters optional parameters, specified as a character, based on 19 | #' what's in your R Markdown file, passed as `params` in the `render()` 20 | #' function in R Markdown. If no parameters are specified here, the 21 | #' function defaults these parameters to 22 | #' `anonymous=TRUE, doublespacing=TRUE, removetitleabstract=TRUE`, 23 | #' which is then wrapped in a list to be passed to the `params` 24 | #' argument in `render()`. Do note this primarily concerns the anonymous 25 | #' manuscript type. These are somewhat advanced-level arguments, so the user 26 | #' should be careful what they do here and should have a firm idea what 27 | #' they are doing here. 28 | #' @param latex_engine the LaTeX engine the user may want to use. 29 | #' Defaults to `"xelatex"`. You can overwrite this if you would like, but 30 | #' why would you? 31 | #' @param dev the graphics device for LaTeX PDFs. Defaults to `"cairo_pdf"`. 32 | #' You can overwrite this, but why would you? 33 | #' 34 | #' @return `render_ms()` takes various arguments, most effectively built 35 | #' into the function, and renders your R Markdown manuscript to various outputs 36 | #' supported by \pkg{stevetemplates}. 37 | #' 38 | #' @examples 39 | #' 40 | #' \dontrun{ 41 | #' render_ms() 42 | #' } 43 | #' 44 | #' @export 45 | #' 46 | 47 | render_ms <- function(file = "ms.Rmd", output_dir = "doc", 48 | outputs = c("pdf", "pdf-anon", "word", "html"), 49 | parameters, latex_engine = "xelatex", dev = "cairo_pdf") { 50 | 51 | if (!all(outputs %in% c("pdf", "pdf-anon", "word", "html"))) { 52 | stop("Invalid outputs are specified. Valid entries here are limited to 'pdf', 'pdf-anon', 'word', and 'html'") 53 | } 54 | 55 | if(pandoc_available() == FALSE) { 56 | stop("R can't find a version of pandoc to use. RStudio has a version of pandoc built into it, but using the original command line interface may lead to an issue like this. Solving this will depend on your particular set up. This solution on Stack Overflow may point to a potential workaround, certainly if you have RStudio installed: https://stackoverflow.com/questions/35624025/pandoc-from-rsudio-server-not-recognized-when-running-script-via-cron") 57 | } 58 | 59 | 60 | 61 | if(missing(parameters)) { 62 | the_params <- eval(parse(text = paste0("list(anonymous=TRUE, doublespacing=TRUE, removetitleabstract=TRUE)"))) 63 | } else { 64 | the_params <- eval(parse(text = paste0("list(", parameters," )"))) 65 | } 66 | 67 | 68 | file_split <- unlist(strsplit(file,"[.]")) 69 | file_name <- file_split[1] 70 | 71 | if("pdf" %in% outputs) { 72 | 73 | 74 | if(is.null(output_dir)) { 75 | 76 | file_location <- paste0(file_name,".pdf") 77 | } else { # assuming an output directory is specified 78 | 79 | file_location <- paste0(output_dir,"/",file_name,".pdf") 80 | 81 | 82 | } 83 | 84 | render(input = file, 85 | output_file = file_location, 86 | pdf_document2(template = templ_article2(), 87 | latex_engine = "xelatex", dev="cairo_pdf", toc = FALSE, 88 | number_sections = FALSE)) 89 | 90 | } 91 | 92 | if("pdf-anon" %in% outputs) { 93 | 94 | if(is.null(output_dir)) { 95 | 96 | file_location <- paste0(file_name,".pdf") 97 | } else { # assuming an output directory is specified 98 | 99 | file_location <- paste0(output_dir,"/",file_name,"-anon.pdf") 100 | 101 | 102 | } 103 | 104 | render(input = file, 105 | output_file = file_location, 106 | params=the_params, 107 | pdf_document2(template = templ_article2(), 108 | latex_engine = "xelatex", dev= "cairo_pdf", toc = FALSE, 109 | number_sections = FALSE)) 110 | 111 | } 112 | 113 | 114 | if("word" %in% outputs) { 115 | 116 | 117 | if(is.null(output_dir)) { 118 | 119 | file_location <- paste0(file_name,".docx") 120 | } else { # assuming an output directory is specified 121 | 122 | file_location <- paste0(output_dir,"/",file_name,".docx") 123 | 124 | 125 | } 126 | 127 | render(input = file, 128 | output_file = file_location, 129 | word_document2(reference_docx = templ_word(), 130 | toc = FALSE, number_sections = FALSE)) 131 | } 132 | 133 | if ("html" %in% outputs) { 134 | 135 | if(is.null(output_dir)) { 136 | 137 | file_location <- paste0(file_name,".html") 138 | } else { # assuming an output directory is specified 139 | 140 | file_location <- paste0(output_dir,"/",file_name,".html") 141 | 142 | 143 | } 144 | 145 | render(input = file, 146 | output_file = file_location, 147 | html_document2(template = templ_html_article(), 148 | toc = FALSE, number_sections = FALSE)) 149 | 150 | } 151 | 152 | } 153 | 154 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | ```{r setup, include = FALSE} 6 | knitr::opts_chunk$set( 7 | collapse = TRUE, 8 | comment = "#>", 9 | out.width = "80%", 10 | fig.align = "center" 11 | ) 12 | ``` 13 | 14 | # Steve's Academic R Projects 15 | 16 | ```{r echo=FALSE, results="hide", message=FALSE} 17 | library("badger") 18 | ``` 19 | 20 | ```{r, echo = FALSE, results='asis'} 21 | cat( 22 | badge_cran_release("steveproj", "green"), 23 | badge_cran_download("steveproj", "grand-total", "green"), 24 | badge_cran_download("steveproj", "last-month", "green"), 25 | badge_cran_download("steveproj", "last-week", "green") 26 | ) 27 | ``` 28 | 29 | My steveproj hexlogo 30 | 31 | `{steveproj}` is an R package to help you start and manage R projects with an eye toward producing an academic project (to culminate in an academic paper). The package is in development and will incorporate other packages in my eponymous R ecosystem, prominently [`{stevetemplates}`](https://github.com/svmiller/stevetemplates). The package itself leans primarily on Rstudio and how it creates/manages projects. The creation a project in Rstudio, through `{steveproj}`, will result in a new directory containing subdirectories for rendering documents (`src/`), R scripts for analysis (`R/`), finished data objects (`data/`), and finished reports (`doc/`). An accompanying `Makefile` and R Markdown file will assist in the management and production of the project. 32 | 33 | ## What It Does (So Far) 34 | 35 | Assuming the latest/development version of [`{stevetemplates}`](https://github.com/svmiller/stevetemplates) (i.e. the one that has the Word template) and considering any potential LaTeX weirdness that comes from different builds, this package has function in R and Make that will: 36 | 37 | - simplify the research process to three basic "targets" (in Make): a finished data product to analyze, statistical models of the data, and post-estimation simulations of quantities of interest from the data. These scripts are in the `R/` directory and render to the `data/` directory. 38 | - render your R Markdown document to a fancy PDF document in LaTeX using [my second article template](http://svmiller.com/blog/2020/09/another-rmarkdown-article-template/). 39 | - render your R Markdown document to an anonymized version of that same document. [A post on my blog](http://svmiller.com/blog/2021/03/handle-academic-projects-steveproj-make/) gives clues how to do this with YAML parameters. 40 | - render your R Markdown document to an anonymized Word document. Anonymized Word documents are all that I'm willing to support here. The goal isn't to publish to Word, per se; it's only to produce a document suitable for peer review for journals that demand you provide one. 41 | - farm your R Markdown document for citations and format them to a bibliography file. By default, this will render to a `refs.bib` file in the `inst/` directory. You can tweak this if you like. 42 | - scan your R Markdown document to render a simple title page for peer review. Traditionally, journals ask for a title page (with author information) and a manuscript (without author information). `render_abstract.R` in the `src/` directory is the companion script to `render_pdf-anon.R` in the same directory. 43 | 44 | ## Installation 45 | 46 | When the time comes, you can install this on CRAN. Any version of this package on CRAN should be understood as a "stable" release that may lag behind the "development" versions available on Github. However, releases on CRAN should come with more confidence about quality control. 47 | 48 | ```r 49 | install.packages("steveproj") 50 | ``` 51 | 52 | A developmental version version of `{steveproj}` is available on Github and you can install it via the `{devtools}` package. I suppose using the `{remotes}` package would work as well. 53 | 54 | ```r 55 | devtools::install_github("svmiller/steveproj") 56 | ``` 57 | 58 | ### A Comment on LaTeX, Make, and Rstudio 59 | 60 | The functions in this package work as intended in an R console, but this package realizes its full potential and its core functions are fully augmented through three additional pieces of software the user should already have installed. The first is [Rstudio](https://www.rstudio.com). Most dedicated R users are likely fully aware of Rstudio as an integrated desktop environment (IDE) and already have it installed and pre-configured to what they think is ideal for their workflow. I will only add that I think it advantageous for the sake of this package to adjust the pane layout such that the "source" pane is top left, the "console" pane is top right, the "environment" pane is bottom left, and the "files" pane is bottom right. 61 | 62 | The second piece of software is [LaTeX](https://www.latex-project.org). LaTeX is a prominent document preparation system in academia and preferred by publishers especially for its contrast to "What You See Is What You Get" word processors like Microsoft Word. `{steveproj}` ultimately places R Markdown and Pandoc---which are necessary for this package---before LaTeX in terms of document preparation. No matter, `{steveproj}` necessarily elevates LaTeX PDF documents above other output types. 63 | 64 | There are two options for installing LaTeX on your system. First, you can install it yourself---in all its 4+ gigabytes of glory. For Mac users, this is "MacTeX" and you can [install it here](http://www.tug.org/mactex/). For Windows users, this is "MikTeX" and you can [install it here](https://miktex.org/). For (Ubuntu) Linux users, something like `sudo apt-get install texlive-base texlive-latex-base texlive-latex-extra` should work. Linux users are probably aware that whatever version of LaTeX comes default in their package manager of choice comes with multiple, complementary packages. Installing even `texlive-base` will probably install more of them as dependencies. 65 | 66 | The second option is tailored for those interested users with no awareness of LaTeX. `{steveproj}` imports `{rmarkdown}`, which in turn imports `{tinytex}`. This would be an R package to install and maintain a version of LaTeX to compile these documents that ostensibly precludes the need to download the more comprehensive suites available on the internet as proper LaTeX distributions for different operating systems. Once `{tinytex}` is installed as an R package, this simple function will install a working version of LaTeX. 67 | 68 | ```r 69 | tinytex::install_tinytex() 70 | ``` 71 | 72 | I will only add that users who do this should know the preferred flavor of LaTeX template (from `{stevetemplates}`) in this package requires one additional LaTeX dependency that `{tinytex}` does not install by default. You may encounter a vague error in rendering to PDF that reads something like this. 73 | 74 | > ! Undefined control sequence. 75 | l.40 \urlstyle 76 | {same} % disable monospaced font for URLs 77 | 78 | If you encounter this error, run the following command in your R console. 79 | 80 | ```r 81 | tinytex::tlmgr_install("xurl") 82 | ``` 83 | 84 | [This should fix it](https://github.com/svmiller/stevetemplates/issues/1). I thank Ian Adams for bringing this to my attention (and Cornelius Hennch for proposing a solution). 85 | 86 | The third piece of software the user should install is [Make](https://en.wikipedia.org/wiki/Make_(software)). Make is a build automation tool built around a "Makefile", which contains a set of recipes that have various targets and dependencies. For each target, if the specified dependency is "newer" than the target (or if the target does not yet exist), the Makefile executes a command. Users will get a reproducible example of how this works, and they can learn by example from it, but it assumes the user already has it installed. 87 | 88 | Installation of Make prior to installation of `{steveproj}` is not necessary; in fact, it's not even strictly necessary to have Make installed at all. It is, however, strongly encouraged. Linux users and Mac users should, in theory, have Make installed on their operating systems already (i.e. because both are UNIX-derivative and Make is a GNU program). Opening a terminal and entering the following command should confirm that. 89 | 90 | ```make 91 | make -v 92 | ``` 93 | 94 | If the console output instead suggests Make is not installed, the user may want to search for how they can install it (given their particular flavor of Mac or Linux). For Mac users, most paths would lead to [installing or updating Xcode from the App Store](https://stackoverflow.com/questions/10265742/how-to-install-make-and-gcc-on-a-mac) though the popular [`Homebrew` package manager](https://brew.sh) should also do this. Linux users in the Debian family (prominently: Ubuntu) who, for some reason, don't already have this installed can install it via `sudo apt-get install build-essential` or `sudo apt-get -y install make` in a console. Linux users in the Red Hat family (prominently: Fedora) should be able to install it by way of `sudo yum install yum-utils` or `dnf install @development-tools`. However, it seems impossible that these would not already be installed on most Linux distributions these days (and for Mac as well). It is one of the oldest and still most widely used GNU programs. No matter, `make -v` should confirm its presence after one of these installation paths. 95 | 96 | Windows users will invariably have to install it since it will not come by default. [*The Carpentries* has a guide](https://swcarpentry.github.io/make-novice/setup) and installer to do this. Windows users may also want to [consider installing `Chocolately`](https://chocolatey.org), an apparent `Homebrew` analog for Windows users. Afterward, a simple `choco install make` command should work just fine. The increased integration of Linux into Windows, prominently [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10), offers more avenues for Windows users to install Make on their operating system. I thank [Dave Braze](https://github.com/davebraze) for alerting me to another option. Windows users can install and configure `make` through installing `{RTools}`. Afterwards, the user can add a fully qualified path to their PATH environment. You can [read more about this process here](https://cran.r-project.org/bin/windows/Rtools/). 97 | 98 | ## Usage 99 | 100 | My website will have a more exhaustive tutorial for using this package and all that comes in it. For now, a user maximize their experience with `{steveproj}` through either the console or Rstudio. 101 | 102 | ### Console 103 | 104 | Assume the current working directory is something like `/home/steve/Dropbox/projects` (as it is for me). Then, a user can create a new project with the `create_project()` command. 105 | 106 | ```{r, eval=F} 107 | steveproj::create_project("dissertation") 108 | ``` 109 | 110 | This will create a new directory in the working directory, titled "dissertation", that includes a skeleton of a research project to assist the user in getting started on their academic paper/project. That directory will be located in the current working directory. The only downside to the console approach over the Rstudio approach is the console approach won't create an `.Rproj` file in the directory. The Rstudio approach will do this. The choice is yours whether you want this, but `.Rproj` files are wonderful for keeping environments insular in Rstudio. 111 | 112 | You could optionally combine this command line call in the console with the following command, which will add an `.Rproj` file to the directory you just created. 113 | 114 | ```{r, eval=F} 115 | # steveproj::create_project("dissertation") 116 | # ^ assume you just ran this 117 | # Then, do this next 118 | steveproj::create_rproj("dissertation") 119 | ``` 120 | 121 | ### Rstudio 122 | 123 | Go to *File > New Project*. You'll see a prompt that looks like this. Select "New Directory". 124 | 125 | ![](http://svmiller.com/images/github-steveproj/steveproj-1.png) 126 | 127 | That will direct you here. Scroll down your available project types until you see my "S" icon, which is incidentally the favicon on [my website](http://svmiller.com). Select that entry to create a new academic paper/project. 128 | 129 | ![](http://svmiller.com/images/github-steveproj/steveproj-2.png) 130 | 131 | That will direct you here. Enter the name of the directory you want to create. Click "Create Project" when you're done. This will create a new directory, titled whatever you entered in the directory name, along with an `.Rproj` file. By default, it will also open a new Rstudio session. 132 | 133 | ![](http://svmiller.com/images/github-steveproj/steveproj-3.png) 134 | 135 | # An Illustration of Automated Workflow in `{steveproj}` 136 | 137 | [The March 15, 2021 post on my blog](http://svmiller.com/blog/2021/03/handle-academic-projects-steveproj-make/) talks more about the design here. Obviously, the skeleton project created in `{steveproj}` is full of gibberish text and an analysis that is likely uninteresting to the user. No matter, the skeleton project points to the possibilities of `{steveproj}` and suggests a template to copy for your own workflow. 138 | 139 | The `Makefile` and `ms.Rmd` files are executable as they are (assuming, obviously, that you installed Make). In Rstudio, switch from the console tab to the terminal tab. Therein, enter the following command (provided the working directory in the terminal is the same as the location of `Makefile`). 140 | 141 | ``` 142 | make all 143 | ``` 144 | 145 | This will run the analyses and compile the results of the analyses into a PDF document, an anonymized PDF document, an anonymized Word document, and an HTML document. It will also generate an title page with abstract. All of those files will be in the `doc/` directory. 146 | 147 | If the user is interested in generating a `.bib` file for their citations, they can execute the following command. 148 | 149 | ``` 150 | make refs 151 | ``` 152 | 153 | This will farm the `ms.Rmd` file for citations and format that as a `refs.bib` file in the `inst/` directory. 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Steve’s Academic R Projects 3 | 4 | [![](https://www.r-pkg.org/badges/version/steveproj?color=green)](https://cran.r-project.org/package=steveproj) 5 | [![](http://cranlogs.r-pkg.org/badges/grand-total/steveproj?color=green)](https://cran.r-project.org/package=steveproj) 6 | [![](http://cranlogs.r-pkg.org/badges/last-month/steveproj?color=green)](https://cran.r-project.org/package=steveproj) 7 | [![](http://cranlogs.r-pkg.org/badges/last-week/steveproj?color=green)](https://cran.r-project.org/package=steveproj) 8 | 9 | My steveproj hexlogo 10 | 11 | `{steveproj}` is an R package to help you start and manage R projects 12 | with an eye toward producing an academic project (to culminate in an 13 | academic paper). The package is in development and will incorporate 14 | other packages in my eponymous R ecosystem, prominently 15 | [`{stevetemplates}`](https://github.com/svmiller/stevetemplates). The 16 | package itself leans primarily on Rstudio and how it creates/manages 17 | projects. The creation a project in Rstudio, through `{steveproj}`, will 18 | result in a new directory containing subdirectories for rendering 19 | documents (`src/`), R scripts for analysis (`R/`), finished data objects 20 | (`data/`), and finished reports (`doc/`). An accompanying `Makefile` and 21 | R Markdown file will assist in the management and production of the 22 | project. 23 | 24 | ## What It Does (So Far) 25 | 26 | Assuming the latest/development version of 27 | [`{stevetemplates}`](https://github.com/svmiller/stevetemplates) 28 | (i.e. the one that has the Word template) and considering any potential 29 | LaTeX weirdness that comes from different builds, this package has 30 | function in R and Make that will: 31 | 32 | - simplify the research process to three basic “targets” (in Make): a 33 | finished data product to analyze, statistical models of the data, 34 | and post-estimation simulations of quantities of interest from the 35 | data. These scripts are in the `R/` directory and render to the 36 | `data/` directory. 37 | - render your R Markdown document to a fancy PDF document in LaTeX 38 | using [my second article 39 | template](http://svmiller.com/blog/2020/09/another-rmarkdown-article-template/). 40 | - render your R Markdown document to an anonymized version of that 41 | same document. [A post on my 42 | blog](http://svmiller.com/blog/2021/03/handle-academic-projects-steveproj-make/) 43 | gives clues how to do this with YAML parameters. 44 | - render your R Markdown document to an anonymized Word document. 45 | Anonymized Word documents are all that I’m willing to support here. 46 | The goal isn’t to publish to Word, per se; it’s only to produce a 47 | document suitable for peer review for journals that demand you 48 | provide one. 49 | - farm your R Markdown document for citations and format them to a 50 | bibliography file. By default, this will render to a `refs.bib` file 51 | in the `inst/` directory. You can tweak this if you like. 52 | - scan your R Markdown document to render a simple title page for peer 53 | review. Traditionally, journals ask for a title page (with author 54 | information) and a manuscript (without author information). 55 | `render_abstract.R` in the `src/` directory is the companion script 56 | to `render_pdf-anon.R` in the same directory. 57 | 58 | ## Installation 59 | 60 | When the time comes, you can install this on CRAN. Any version of this 61 | package on CRAN should be understood as a “stable” release that may lag 62 | behind the “development” versions available on Github. However, releases 63 | on CRAN should come with more confidence about quality control. 64 | 65 | ``` r 66 | install.packages("steveproj") 67 | ``` 68 | 69 | A developmental version version of `{steveproj}` is available on Github 70 | and you can install it via the `{devtools}` package. I suppose using the 71 | `{remotes}` package would work as well. 72 | 73 | ``` r 74 | devtools::install_github("svmiller/steveproj") 75 | ``` 76 | 77 | ### A Comment on LaTeX, Make, and Rstudio 78 | 79 | The functions in this package work as intended in an R console, but this 80 | package realizes its full potential and its core functions are fully 81 | augmented through three additional pieces of software the user should 82 | already have installed. The first is [Rstudio](https://www.rstudio.com). 83 | Most dedicated R users are likely fully aware of Rstudio as an 84 | integrated desktop environment (IDE) and already have it installed and 85 | pre-configured to what they think is ideal for their workflow. I will 86 | only add that I think it advantageous for the sake of this package to 87 | adjust the pane layout such that the “source” pane is top left, the 88 | “console” pane is top right, the “environment” pane is bottom left, and 89 | the “files” pane is bottom right. 90 | 91 | The second piece of software is [LaTeX](https://www.latex-project.org). 92 | LaTeX is a prominent document preparation system in academia and 93 | preferred by publishers especially for its contrast to “What You See Is 94 | What You Get” word processors like Microsoft Word. `{steveproj}` 95 | ultimately places R Markdown and Pandoc—which are necessary for this 96 | package—before LaTeX in terms of document preparation. No matter, 97 | `{steveproj}` necessarily elevates LaTeX PDF documents above other 98 | output types. 99 | 100 | There are two options for installing LaTeX on your system. First, you 101 | can install it yourself—in all its 4+ gigabytes of glory. For Mac users, 102 | this is “MacTeX” and you can [install it 103 | here](http://www.tug.org/mactex/). For Windows users, this is “MikTeX” 104 | and you can [install it here](https://miktex.org/). For (Ubuntu) Linux 105 | users, something like 106 | `sudo apt-get install texlive-base texlive-latex-base texlive-latex-extra` 107 | should work. Linux users are probably aware that whatever version of 108 | LaTeX comes default in their package manager of choice comes with 109 | multiple, complementary packages. Installing even `texlive-base` will 110 | probably install more of them as dependencies. 111 | 112 | The second option is tailored for those interested users with no 113 | awareness of LaTeX. `{steveproj}` imports `{rmarkdown}`, which in turn 114 | imports `{tinytex}`. This would be an R package to install and maintain 115 | a version of LaTeX to compile these documents that ostensibly precludes 116 | the need to download the more comprehensive suites available on the 117 | internet as proper LaTeX distributions for different operating systems. 118 | Once `{tinytex}` is installed as an R package, this simple function will 119 | install a working version of LaTeX. 120 | 121 | ``` r 122 | tinytex::install_tinytex() 123 | ``` 124 | 125 | I will only add that users who do this should know the preferred flavor 126 | of LaTeX template (from `{stevetemplates}`) in this package requires one 127 | additional LaTeX dependency that `{tinytex}` does not install by 128 | default. You may encounter a vague error in rendering to PDF that reads 129 | something like this. 130 | 131 | > ! Undefined control sequence. l.40 {same} % disable monospaced font 132 | > for URLs 133 | 134 | If you encounter this error, run the following command in your R 135 | console. 136 | 137 | ``` r 138 | tinytex::tlmgr_install("xurl") 139 | ``` 140 | 141 | [This should fix 142 | it](https://github.com/svmiller/stevetemplates/issues/1). I thank Ian 143 | Adams for bringing this to my attention (and Cornelius Hennch for 144 | proposing a solution). 145 | 146 | The third piece of software the user should install is 147 | [Make](https://en.wikipedia.org/wiki/Make_(software)). Make is a build 148 | automation tool built around a “Makefile”, which contains a set of 149 | recipes that have various targets and dependencies. For each target, if 150 | the specified dependency is “newer” than the target (or if the target 151 | does not yet exist), the Makefile executes a command. Users will get a 152 | reproducible example of how this works, and they can learn by example 153 | from it, but it assumes the user already has it installed. 154 | 155 | Installation of Make prior to installation of `{steveproj}` is not 156 | necessary; in fact, it’s not even strictly necessary to have Make 157 | installed at all. It is, however, strongly encouraged. Linux users and 158 | Mac users should, in theory, have Make installed on their operating 159 | systems already (i.e. because both are UNIX-derivative and Make is a GNU 160 | program). Opening a terminal and entering the following command should 161 | confirm that. 162 | 163 | ``` make 164 | make -v 165 | ``` 166 | 167 | If the console output instead suggests Make is not installed, the user 168 | may want to search for how they can install it (given their particular 169 | flavor of Mac or Linux). For Mac users, most paths would lead to 170 | [installing or updating Xcode from the App 171 | Store](https://stackoverflow.com/questions/10265742/how-to-install-make-and-gcc-on-a-mac) 172 | though the popular [`Homebrew` package manager](https://brew.sh) should 173 | also do this. Linux users in the Debian family (prominently: Ubuntu) 174 | who, for some reason, don’t already have this installed can install it 175 | via `sudo apt-get install build-essential` or 176 | `sudo apt-get -y install make` in a console. Linux users in the Red Hat 177 | family (prominently: Fedora) should be able to install it by way of 178 | `sudo yum install yum-utils` or `dnf install @development-tools`. 179 | However, it seems impossible that these would not already be installed 180 | on most Linux distributions these days (and for Mac as well). It is one 181 | of the oldest and still most widely used GNU programs. No matter, 182 | `make -v` should confirm its presence after one of these installation 183 | paths. 184 | 185 | Windows users will invariably have to install it since it will not come 186 | by default. [*The Carpentries* has a 187 | guide](https://swcarpentry.github.io/make-novice/setup) and installer to 188 | do this. Windows users may also want to [consider installing 189 | `Chocolately`](https://chocolatey.org), an apparent `Homebrew` analog 190 | for Windows users. Afterward, a simple `choco install make` command 191 | should work just fine. The increased integration of Linux into Windows, 192 | prominently [Windows Subsystem for 193 | Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10), 194 | offers more avenues for Windows users to install Make on their operating 195 | system. I thank [Dave Braze](https://github.com/davebraze) for alerting 196 | me to another option. Windows users can install and configure `make` 197 | through installing `{RTools}`. Afterwards, the user can add a fully 198 | qualified path to their PATH environment. You can [read more about this 199 | process here](https://cran.r-project.org/bin/windows/Rtools/). 200 | 201 | ## Usage 202 | 203 | My website will have a more exhaustive tutorial for using this package 204 | and all that comes in it. For now, a user maximize their experience with 205 | `{steveproj}` through either the console or Rstudio. 206 | 207 | ### Console 208 | 209 | Assume the current working directory is something like 210 | `/home/steve/Dropbox/projects` (as it is for me). Then, a user can 211 | create a new project with the `create_project()` command. 212 | 213 | ``` r 214 | steveproj::create_project("dissertation") 215 | ``` 216 | 217 | This will create a new directory in the working directory, titled 218 | “dissertation”, that includes a skeleton of a research project to assist 219 | the user in getting started on their academic paper/project. That 220 | directory will be located in the current working directory. The only 221 | downside to the console approach over the Rstudio approach is the 222 | console approach won’t create an `.Rproj` file in the directory. The 223 | Rstudio approach will do this. The choice is yours whether you want 224 | this, but `.Rproj` files are wonderful for keeping environments insular 225 | in Rstudio. 226 | 227 | You could optionally combine this command line call in the console with 228 | the following command, which will add an `.Rproj` file to the directory 229 | you just created. 230 | 231 | ``` r 232 | # steveproj::create_project("dissertation") 233 | # ^ assume you just ran this 234 | # Then, do this next 235 | steveproj::create_rproj("dissertation") 236 | ``` 237 | 238 | ### Rstudio 239 | 240 | Go to *File > New Project*. You’ll see a prompt that looks like this. 241 | Select “New Directory”. 242 | 243 | ![](http://svmiller.com/images/github-steveproj/steveproj-1.png) 244 | 245 | That will direct you here. Scroll down your available project types 246 | until you see my “S” icon, which is incidentally the favicon on [my 247 | website](http://svmiller.com). Select that entry to create a new 248 | academic paper/project. 249 | 250 | ![](http://svmiller.com/images/github-steveproj/steveproj-2.png) 251 | 252 | That will direct you here. Enter the name of the directory you want to 253 | create. Click “Create Project” when you’re done. This will create a new 254 | directory, titled whatever you entered in the directory name, along with 255 | an `.Rproj` file. By default, it will also open a new Rstudio session. 256 | 257 | ![](http://svmiller.com/images/github-steveproj/steveproj-3.png) 258 | 259 | # An Illustration of Automated Workflow in `{steveproj}` 260 | 261 | [The March 15, 2021 post on my 262 | blog](http://svmiller.com/blog/2021/03/handle-academic-projects-steveproj-make/) 263 | talks more about the design here. Obviously, the skeleton project 264 | created in `{steveproj}` is full of gibberish text and an analysis that 265 | is likely uninteresting to the user. No matter, the skeleton project 266 | points to the possibilities of `{steveproj}` and suggests a template to 267 | copy for your own workflow. 268 | 269 | The `Makefile` and `ms.Rmd` files are executable as they are (assuming, 270 | obviously, that you installed Make). In Rstudio, switch from the console 271 | tab to the terminal tab. Therein, enter the following command (provided 272 | the working directory in the terminal is the same as the location of 273 | `Makefile`). 274 | 275 | make all 276 | 277 | This will run the analyses and compile the results of the analyses into 278 | a PDF document, an anonymized PDF document, an anonymized Word document, 279 | and an HTML document. It will also generate an title page with abstract. 280 | All of those files will be in the `doc/` directory. 281 | 282 | If the user is interested in generating a `.bib` file for their 283 | citations, they can execute the following command. 284 | 285 | make refs 286 | 287 | This will farm the `ms.Rmd` file for citations and format that as a 288 | `refs.bib` file in the `inst/` directory. 289 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: http://svmiller.com 2 | 3 | template: 4 | params: 5 | bootswatch: journal 6 | 7 | figures: 8 | fig.width: 11 9 | -------------------------------------------------------------------------------- /docs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Page not found (404) • steveproj 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
64 |
65 | 104 | 105 | 106 | 107 |
108 | 109 |
110 |
111 | 114 | 115 | Content not found. Please use links in the navbar. 116 | 117 |
118 | 119 | 124 | 125 |
126 | 127 | 128 | 129 |
130 | 133 | 134 |
135 |

Site built with pkgdown 1.6.1.

136 |
137 | 138 |
139 |
140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /docs/authors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Authors • steveproj 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
64 |
65 | 104 | 105 | 106 | 107 |
108 | 109 |
110 |
111 | 114 | 115 |
    116 |
  • 117 |

    Steven V. Miller. Maintainer. 118 |

    119 |
  • 120 |
121 | 122 |
123 | 124 |
125 | 126 | 127 | 128 |
129 | 132 | 133 |
134 |

Site built with pkgdown 1.6.1.

135 |
136 | 137 |
138 |
139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | 6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ 7 | 8 | /* All levels of nav */ 9 | nav[data-toggle='toc'] .nav > li > a { 10 | display: block; 11 | padding: 4px 20px; 12 | font-size: 13px; 13 | font-weight: 500; 14 | color: #767676; 15 | } 16 | nav[data-toggle='toc'] .nav > li > a:hover, 17 | nav[data-toggle='toc'] .nav > li > a:focus { 18 | padding-left: 19px; 19 | color: #563d7c; 20 | text-decoration: none; 21 | background-color: transparent; 22 | border-left: 1px solid #563d7c; 23 | } 24 | nav[data-toggle='toc'] .nav > .active > a, 25 | nav[data-toggle='toc'] .nav > .active:hover > a, 26 | nav[data-toggle='toc'] .nav > .active:focus > a { 27 | padding-left: 18px; 28 | font-weight: bold; 29 | color: #563d7c; 30 | background-color: transparent; 31 | border-left: 2px solid #563d7c; 32 | } 33 | 34 | /* Nav: second level (shown on .active) */ 35 | nav[data-toggle='toc'] .nav .nav { 36 | display: none; /* Hide by default, but at >768px, show it */ 37 | padding-bottom: 10px; 38 | } 39 | nav[data-toggle='toc'] .nav .nav > li > a { 40 | padding-top: 1px; 41 | padding-bottom: 1px; 42 | padding-left: 30px; 43 | font-size: 12px; 44 | font-weight: normal; 45 | } 46 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 47 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 48 | padding-left: 29px; 49 | } 50 | nav[data-toggle='toc'] .nav .nav > .active > a, 51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 53 | padding-left: 28px; 54 | font-weight: 500; 55 | } 56 | 57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ 58 | nav[data-toggle='toc'] .nav > .active > ul { 59 | display: block; 60 | } 61 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | (function() { 6 | 'use strict'; 7 | 8 | window.Toc = { 9 | helpers: { 10 | // return all matching elements in the set, or their descendants 11 | findOrFilter: function($el, selector) { 12 | // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ 13 | // http://stackoverflow.com/a/12731439/358804 14 | var $descendants = $el.find(selector); 15 | return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); 16 | }, 17 | 18 | generateUniqueIdBase: function(el) { 19 | var text = $(el).text(); 20 | var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); 21 | return anchor || el.tagName.toLowerCase(); 22 | }, 23 | 24 | generateUniqueId: function(el) { 25 | var anchorBase = this.generateUniqueIdBase(el); 26 | for (var i = 0; ; i++) { 27 | var anchor = anchorBase; 28 | if (i > 0) { 29 | // add suffix 30 | anchor += '-' + i; 31 | } 32 | // check if ID already exists 33 | if (!document.getElementById(anchor)) { 34 | return anchor; 35 | } 36 | } 37 | }, 38 | 39 | generateAnchor: function(el) { 40 | if (el.id) { 41 | return el.id; 42 | } else { 43 | var anchor = this.generateUniqueId(el); 44 | el.id = anchor; 45 | return anchor; 46 | } 47 | }, 48 | 49 | createNavList: function() { 50 | return $(''); 51 | }, 52 | 53 | createChildNavList: function($parent) { 54 | var $childList = this.createNavList(); 55 | $parent.append($childList); 56 | return $childList; 57 | }, 58 | 59 | generateNavEl: function(anchor, text) { 60 | var $a = $(''); 61 | $a.attr('href', '#' + anchor); 62 | $a.text(text); 63 | var $li = $('
  • '); 64 | $li.append($a); 65 | return $li; 66 | }, 67 | 68 | generateNavItem: function(headingEl) { 69 | var anchor = this.generateAnchor(headingEl); 70 | var $heading = $(headingEl); 71 | var text = $heading.data('toc-text') || $heading.text(); 72 | return this.generateNavEl(anchor, text); 73 | }, 74 | 75 | // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). 76 | getTopLevel: function($scope) { 77 | for (var i = 1; i <= 6; i++) { 78 | var $headings = this.findOrFilter($scope, 'h' + i); 79 | if ($headings.length > 1) { 80 | return i; 81 | } 82 | } 83 | 84 | return 1; 85 | }, 86 | 87 | // returns the elements for the top level, and the next below it 88 | getHeadings: function($scope, topLevel) { 89 | var topSelector = 'h' + topLevel; 90 | 91 | var secondaryLevel = topLevel + 1; 92 | var secondarySelector = 'h' + secondaryLevel; 93 | 94 | return this.findOrFilter($scope, topSelector + ',' + secondarySelector); 95 | }, 96 | 97 | getNavLevel: function(el) { 98 | return parseInt(el.tagName.charAt(1), 10); 99 | }, 100 | 101 | populateNav: function($topContext, topLevel, $headings) { 102 | var $context = $topContext; 103 | var $prevNav; 104 | 105 | var helpers = this; 106 | $headings.each(function(i, el) { 107 | var $newNav = helpers.generateNavItem(el); 108 | var navLevel = helpers.getNavLevel(el); 109 | 110 | // determine the proper $context 111 | if (navLevel === topLevel) { 112 | // use top level 113 | $context = $topContext; 114 | } else if ($prevNav && $context === $topContext) { 115 | // create a new level of the tree and switch to it 116 | $context = helpers.createChildNavList($prevNav); 117 | } // else use the current $context 118 | 119 | $context.append($newNav); 120 | 121 | $prevNav = $newNav; 122 | }); 123 | }, 124 | 125 | parseOps: function(arg) { 126 | var opts; 127 | if (arg.jquery) { 128 | opts = { 129 | $nav: arg 130 | }; 131 | } else { 132 | opts = arg; 133 | } 134 | opts.$scope = opts.$scope || $(document.body); 135 | return opts; 136 | } 137 | }, 138 | 139 | // accepts a jQuery object, or an options object 140 | init: function(opts) { 141 | opts = this.helpers.parseOps(opts); 142 | 143 | // ensure that the data attribute is in place for styling 144 | opts.$nav.attr('data-toggle', 'toc'); 145 | 146 | var $topContext = this.helpers.createChildNavList(opts.$nav); 147 | var topLevel = this.helpers.getTopLevel(opts.$scope); 148 | var $headings = this.helpers.getHeadings(opts.$scope, topLevel); 149 | this.helpers.populateNav($topContext, topLevel, $headings); 150 | } 151 | }; 152 | 153 | $(function() { 154 | $('nav[data-toggle="toc"]').each(function(i, el) { 155 | var $nav = $(el); 156 | Toc.init($nav); 157 | }); 158 | }); 159 | })(); 160 | -------------------------------------------------------------------------------- /docs/docsearch.css: -------------------------------------------------------------------------------- 1 | /* Docsearch -------------------------------------------------------------- */ 2 | /* 3 | Source: https://github.com/algolia/docsearch/ 4 | License: MIT 5 | */ 6 | 7 | .algolia-autocomplete { 8 | display: block; 9 | -webkit-box-flex: 1; 10 | -ms-flex: 1; 11 | flex: 1 12 | } 13 | 14 | .algolia-autocomplete .ds-dropdown-menu { 15 | width: 100%; 16 | min-width: none; 17 | max-width: none; 18 | padding: .75rem 0; 19 | background-color: #fff; 20 | background-clip: padding-box; 21 | border: 1px solid rgba(0, 0, 0, .1); 22 | box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175); 23 | } 24 | 25 | @media (min-width:768px) { 26 | .algolia-autocomplete .ds-dropdown-menu { 27 | width: 175% 28 | } 29 | } 30 | 31 | .algolia-autocomplete .ds-dropdown-menu::before { 32 | display: none 33 | } 34 | 35 | .algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] { 36 | padding: 0; 37 | background-color: rgb(255,255,255); 38 | border: 0; 39 | max-height: 80vh; 40 | } 41 | 42 | .algolia-autocomplete .ds-dropdown-menu .ds-suggestions { 43 | margin-top: 0 44 | } 45 | 46 | .algolia-autocomplete .algolia-docsearch-suggestion { 47 | padding: 0; 48 | overflow: visible 49 | } 50 | 51 | .algolia-autocomplete .algolia-docsearch-suggestion--category-header { 52 | padding: .125rem 1rem; 53 | margin-top: 0; 54 | font-size: 1.3em; 55 | font-weight: 500; 56 | color: #00008B; 57 | border-bottom: 0 58 | } 59 | 60 | .algolia-autocomplete .algolia-docsearch-suggestion--wrapper { 61 | float: none; 62 | padding-top: 0 63 | } 64 | 65 | .algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { 66 | float: none; 67 | width: auto; 68 | padding: 0; 69 | text-align: left 70 | } 71 | 72 | .algolia-autocomplete .algolia-docsearch-suggestion--content { 73 | float: none; 74 | width: auto; 75 | padding: 0 76 | } 77 | 78 | .algolia-autocomplete .algolia-docsearch-suggestion--content::before { 79 | display: none 80 | } 81 | 82 | .algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header { 83 | padding-top: .75rem; 84 | margin-top: .75rem; 85 | border-top: 1px solid rgba(0, 0, 0, .1) 86 | } 87 | 88 | .algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column { 89 | display: block; 90 | padding: .1rem 1rem; 91 | margin-bottom: 0.1; 92 | font-size: 1.0em; 93 | font-weight: 400 94 | /* display: none */ 95 | } 96 | 97 | .algolia-autocomplete .algolia-docsearch-suggestion--title { 98 | display: block; 99 | padding: .25rem 1rem; 100 | margin-bottom: 0; 101 | font-size: 0.9em; 102 | font-weight: 400 103 | } 104 | 105 | .algolia-autocomplete .algolia-docsearch-suggestion--text { 106 | padding: 0 1rem .5rem; 107 | margin-top: -.25rem; 108 | font-size: 0.8em; 109 | font-weight: 400; 110 | line-height: 1.25 111 | } 112 | 113 | .algolia-autocomplete .algolia-docsearch-footer { 114 | width: 110px; 115 | height: 20px; 116 | z-index: 3; 117 | margin-top: 10.66667px; 118 | float: right; 119 | font-size: 0; 120 | line-height: 0; 121 | } 122 | 123 | .algolia-autocomplete .algolia-docsearch-footer--logo { 124 | background-image: url("data:image/svg+xml;utf8,"); 125 | background-repeat: no-repeat; 126 | background-position: 50%; 127 | background-size: 100%; 128 | overflow: hidden; 129 | text-indent: -9000px; 130 | width: 100%; 131 | height: 100%; 132 | display: block; 133 | transform: translate(-8px); 134 | } 135 | 136 | .algolia-autocomplete .algolia-docsearch-suggestion--highlight { 137 | color: #FF8C00; 138 | background: rgba(232, 189, 54, 0.1) 139 | } 140 | 141 | 142 | .algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight { 143 | box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5) 144 | } 145 | 146 | .algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content { 147 | background-color: rgba(192, 192, 192, .15) 148 | } 149 | -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /docs/extra.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i'); 2 | @import url('https://fonts.googleapis.com/css?family=Titillium+Web:300,300i,400,400i,600,600i,700,700i'); 3 | @import url('https://fonts.googleapis.com/css?family=Fira+Code:400'); 4 | 5 | 6 | body { 7 | font-family: 'Open Sans', Helvetica, Arial, sans-serif; 8 | font-size: 11.5pt; 9 | line-height: 1.5; 10 | font-weight: 300; 11 | color: #111111; 12 | } 13 | 14 | h1, h2, h3, h4, h5, h6 { 15 | font-family: 'Titillium Web', serif; 16 | } 17 | 18 | code { 19 | padding: 1px; 20 | background-color: #fff; 21 | font-family: 'Fira Code', monospace; 22 | } 23 | -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /docs/pkgdown.css: -------------------------------------------------------------------------------- 1 | /* Sticky footer */ 2 | 3 | /** 4 | * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ 5 | * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css 6 | * 7 | * .Site -> body > .container 8 | * .Site-content -> body > .container .row 9 | * .footer -> footer 10 | * 11 | * Key idea seems to be to ensure that .container and __all its parents__ 12 | * have height set to 100% 13 | * 14 | */ 15 | 16 | html, body { 17 | height: 100%; 18 | } 19 | 20 | body { 21 | position: relative; 22 | } 23 | 24 | body > .container { 25 | display: flex; 26 | height: 100%; 27 | flex-direction: column; 28 | } 29 | 30 | body > .container .row { 31 | flex: 1 0 auto; 32 | } 33 | 34 | footer { 35 | margin-top: 45px; 36 | padding: 35px 0 36px; 37 | border-top: 1px solid #e5e5e5; 38 | color: #666; 39 | display: flex; 40 | flex-shrink: 0; 41 | } 42 | footer p { 43 | margin-bottom: 0; 44 | } 45 | footer div { 46 | flex: 1; 47 | } 48 | footer .pkgdown { 49 | text-align: right; 50 | } 51 | footer p { 52 | margin-bottom: 0; 53 | } 54 | 55 | img.icon { 56 | float: right; 57 | } 58 | 59 | img { 60 | max-width: 100%; 61 | } 62 | 63 | /* Fix bug in bootstrap (only seen in firefox) */ 64 | summary { 65 | display: list-item; 66 | } 67 | 68 | /* Typographic tweaking ---------------------------------*/ 69 | 70 | .contents .page-header { 71 | margin-top: calc(-60px + 1em); 72 | } 73 | 74 | dd { 75 | margin-left: 3em; 76 | } 77 | 78 | /* Section anchors ---------------------------------*/ 79 | 80 | a.anchor { 81 | margin-left: -30px; 82 | display:inline-block; 83 | width: 30px; 84 | height: 30px; 85 | visibility: hidden; 86 | 87 | background-image: url(./link.svg); 88 | background-repeat: no-repeat; 89 | background-size: 20px 20px; 90 | background-position: center center; 91 | } 92 | 93 | .hasAnchor:hover a.anchor { 94 | visibility: visible; 95 | } 96 | 97 | @media (max-width: 767px) { 98 | .hasAnchor:hover a.anchor { 99 | visibility: hidden; 100 | } 101 | } 102 | 103 | 104 | /* Fixes for fixed navbar --------------------------*/ 105 | 106 | .contents h1, .contents h2, .contents h3, .contents h4 { 107 | padding-top: 60px; 108 | margin-top: -40px; 109 | } 110 | 111 | /* Navbar submenu --------------------------*/ 112 | 113 | .dropdown-submenu { 114 | position: relative; 115 | } 116 | 117 | .dropdown-submenu>.dropdown-menu { 118 | top: 0; 119 | left: 100%; 120 | margin-top: -6px; 121 | margin-left: -1px; 122 | border-radius: 0 6px 6px 6px; 123 | } 124 | 125 | .dropdown-submenu:hover>.dropdown-menu { 126 | display: block; 127 | } 128 | 129 | .dropdown-submenu>a:after { 130 | display: block; 131 | content: " "; 132 | float: right; 133 | width: 0; 134 | height: 0; 135 | border-color: transparent; 136 | border-style: solid; 137 | border-width: 5px 0 5px 5px; 138 | border-left-color: #cccccc; 139 | margin-top: 5px; 140 | margin-right: -10px; 141 | } 142 | 143 | .dropdown-submenu:hover>a:after { 144 | border-left-color: #ffffff; 145 | } 146 | 147 | .dropdown-submenu.pull-left { 148 | float: none; 149 | } 150 | 151 | .dropdown-submenu.pull-left>.dropdown-menu { 152 | left: -100%; 153 | margin-left: 10px; 154 | border-radius: 6px 0 6px 6px; 155 | } 156 | 157 | /* Sidebar --------------------------*/ 158 | 159 | #pkgdown-sidebar { 160 | margin-top: 30px; 161 | position: -webkit-sticky; 162 | position: sticky; 163 | top: 70px; 164 | } 165 | 166 | #pkgdown-sidebar h2 { 167 | font-size: 1.5em; 168 | margin-top: 1em; 169 | } 170 | 171 | #pkgdown-sidebar h2:first-child { 172 | margin-top: 0; 173 | } 174 | 175 | #pkgdown-sidebar .list-unstyled li { 176 | margin-bottom: 0.5em; 177 | } 178 | 179 | /* bootstrap-toc tweaks ------------------------------------------------------*/ 180 | 181 | /* All levels of nav */ 182 | 183 | nav[data-toggle='toc'] .nav > li > a { 184 | padding: 4px 20px 4px 6px; 185 | font-size: 1.5rem; 186 | font-weight: 400; 187 | color: inherit; 188 | } 189 | 190 | nav[data-toggle='toc'] .nav > li > a:hover, 191 | nav[data-toggle='toc'] .nav > li > a:focus { 192 | padding-left: 5px; 193 | color: inherit; 194 | border-left: 1px solid #878787; 195 | } 196 | 197 | nav[data-toggle='toc'] .nav > .active > a, 198 | nav[data-toggle='toc'] .nav > .active:hover > a, 199 | nav[data-toggle='toc'] .nav > .active:focus > a { 200 | padding-left: 5px; 201 | font-size: 1.5rem; 202 | font-weight: 400; 203 | color: inherit; 204 | border-left: 2px solid #878787; 205 | } 206 | 207 | /* Nav: second level (shown on .active) */ 208 | 209 | nav[data-toggle='toc'] .nav .nav { 210 | display: none; /* Hide by default, but at >768px, show it */ 211 | padding-bottom: 10px; 212 | } 213 | 214 | nav[data-toggle='toc'] .nav .nav > li > a { 215 | padding-left: 16px; 216 | font-size: 1.35rem; 217 | } 218 | 219 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 220 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 221 | padding-left: 15px; 222 | } 223 | 224 | nav[data-toggle='toc'] .nav .nav > .active > a, 225 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 226 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 227 | padding-left: 15px; 228 | font-weight: 500; 229 | font-size: 1.35rem; 230 | } 231 | 232 | /* orcid ------------------------------------------------------------------- */ 233 | 234 | .orcid { 235 | font-size: 16px; 236 | color: #A6CE39; 237 | /* margins are required by official ORCID trademark and display guidelines */ 238 | margin-left:4px; 239 | margin-right:4px; 240 | vertical-align: middle; 241 | } 242 | 243 | /* Reference index & topics ----------------------------------------------- */ 244 | 245 | .ref-index th {font-weight: normal;} 246 | 247 | .ref-index td {vertical-align: top; min-width: 100px} 248 | .ref-index .icon {width: 40px;} 249 | .ref-index .alias {width: 40%;} 250 | .ref-index-icons .alias {width: calc(40% - 40px);} 251 | .ref-index .title {width: 60%;} 252 | 253 | .ref-arguments th {text-align: right; padding-right: 10px;} 254 | .ref-arguments th, .ref-arguments td {vertical-align: top; min-width: 100px} 255 | .ref-arguments .name {width: 20%;} 256 | .ref-arguments .desc {width: 80%;} 257 | 258 | /* Nice scrolling for wide elements --------------------------------------- */ 259 | 260 | table { 261 | display: block; 262 | overflow: auto; 263 | } 264 | 265 | /* Syntax highlighting ---------------------------------------------------- */ 266 | 267 | pre { 268 | word-wrap: normal; 269 | word-break: normal; 270 | border: 1px solid #eee; 271 | } 272 | 273 | pre, code { 274 | background-color: #f8f8f8; 275 | color: #333; 276 | } 277 | 278 | pre code { 279 | overflow: auto; 280 | word-wrap: normal; 281 | white-space: pre; 282 | } 283 | 284 | pre .img { 285 | margin: 5px 0; 286 | } 287 | 288 | pre .img img { 289 | background-color: #fff; 290 | display: block; 291 | height: auto; 292 | } 293 | 294 | code a, pre a { 295 | color: #375f84; 296 | } 297 | 298 | a.sourceLine:hover { 299 | text-decoration: none; 300 | } 301 | 302 | .fl {color: #1514b5;} 303 | .fu {color: #000000;} /* function */ 304 | .ch,.st {color: #036a07;} /* string */ 305 | .kw {color: #264D66;} /* keyword */ 306 | .co {color: #888888;} /* comment */ 307 | 308 | .message { color: black; font-weight: bolder;} 309 | .error { color: orange; font-weight: bolder;} 310 | .warning { color: #6A0366; font-weight: bolder;} 311 | 312 | /* Clipboard --------------------------*/ 313 | 314 | .hasCopyButton { 315 | position: relative; 316 | } 317 | 318 | .btn-copy-ex { 319 | position: absolute; 320 | right: 0; 321 | top: 0; 322 | visibility: hidden; 323 | } 324 | 325 | .hasCopyButton:hover button.btn-copy-ex { 326 | visibility: visible; 327 | } 328 | 329 | /* headroom.js ------------------------ */ 330 | 331 | .headroom { 332 | will-change: transform; 333 | transition: transform 200ms linear; 334 | } 335 | .headroom--pinned { 336 | transform: translateY(0%); 337 | } 338 | .headroom--unpinned { 339 | transform: translateY(-100%); 340 | } 341 | 342 | /* mark.js ----------------------------*/ 343 | 344 | mark { 345 | background-color: rgba(255, 255, 51, 0.5); 346 | border-bottom: 2px solid rgba(255, 153, 51, 0.3); 347 | padding: 1px; 348 | } 349 | 350 | /* vertical spacing after htmlwidgets */ 351 | .html-widget { 352 | margin-bottom: 10px; 353 | } 354 | 355 | /* fontawesome ------------------------ */ 356 | 357 | .fab { 358 | font-family: "Font Awesome 5 Brands" !important; 359 | } 360 | 361 | /* don't display links in code chunks when printing */ 362 | /* source: https://stackoverflow.com/a/10781533 */ 363 | @media print { 364 | code a:link:after, code a:visited:after { 365 | content: ""; 366 | } 367 | } 368 | -------------------------------------------------------------------------------- /docs/pkgdown.js: -------------------------------------------------------------------------------- 1 | /* http://gregfranko.com/blog/jquery-best-practices/ */ 2 | (function($) { 3 | $(function() { 4 | 5 | $('.navbar-fixed-top').headroom(); 6 | 7 | $('body').css('padding-top', $('.navbar').height() + 10); 8 | $(window).resize(function(){ 9 | $('body').css('padding-top', $('.navbar').height() + 10); 10 | }); 11 | 12 | $('[data-toggle="tooltip"]').tooltip(); 13 | 14 | var cur_path = paths(location.pathname); 15 | var links = $("#navbar ul li a"); 16 | var max_length = -1; 17 | var pos = -1; 18 | for (var i = 0; i < links.length; i++) { 19 | if (links[i].getAttribute("href") === "#") 20 | continue; 21 | // Ignore external links 22 | if (links[i].host !== location.host) 23 | continue; 24 | 25 | var nav_path = paths(links[i].pathname); 26 | 27 | var length = prefix_length(nav_path, cur_path); 28 | if (length > max_length) { 29 | max_length = length; 30 | pos = i; 31 | } 32 | } 33 | 34 | // Add class to parent
  • , and enclosing
  • if in dropdown 35 | if (pos >= 0) { 36 | var menu_anchor = $(links[pos]); 37 | menu_anchor.parent().addClass("active"); 38 | menu_anchor.closest("li.dropdown").addClass("active"); 39 | } 40 | }); 41 | 42 | function paths(pathname) { 43 | var pieces = pathname.split("/"); 44 | pieces.shift(); // always starts with / 45 | 46 | var end = pieces[pieces.length - 1]; 47 | if (end === "index.html" || end === "") 48 | pieces.pop(); 49 | return(pieces); 50 | } 51 | 52 | // Returns -1 if not found 53 | function prefix_length(needle, haystack) { 54 | if (needle.length > haystack.length) 55 | return(-1); 56 | 57 | // Special case for length-0 haystack, since for loop won't run 58 | if (haystack.length === 0) { 59 | return(needle.length === 0 ? 0 : -1); 60 | } 61 | 62 | for (var i = 0; i < haystack.length; i++) { 63 | if (needle[i] != haystack[i]) 64 | return(i); 65 | } 66 | 67 | return(haystack.length); 68 | } 69 | 70 | /* Clipboard --------------------------*/ 71 | 72 | function changeTooltipMessage(element, msg) { 73 | var tooltipOriginalTitle=element.getAttribute('data-original-title'); 74 | element.setAttribute('data-original-title', msg); 75 | $(element).tooltip('show'); 76 | element.setAttribute('data-original-title', tooltipOriginalTitle); 77 | } 78 | 79 | if(ClipboardJS.isSupported()) { 80 | $(document).ready(function() { 81 | var copyButton = ""; 82 | 83 | $(".examples, div.sourceCode").addClass("hasCopyButton"); 84 | 85 | // Insert copy buttons: 86 | $(copyButton).prependTo(".hasCopyButton"); 87 | 88 | // Initialize tooltips: 89 | $('.btn-copy-ex').tooltip({container: 'body'}); 90 | 91 | // Initialize clipboard: 92 | var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { 93 | text: function(trigger) { 94 | return trigger.parentNode.textContent; 95 | } 96 | }); 97 | 98 | clipboardBtnCopies.on('success', function(e) { 99 | changeTooltipMessage(e.trigger, 'Copied!'); 100 | e.clearSelection(); 101 | }); 102 | 103 | clipboardBtnCopies.on('error', function() { 104 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); 105 | }); 106 | }); 107 | } 108 | })(window.jQuery || window.$) 109 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: 2.11.4 2 | pkgdown: 1.6.1 3 | pkgdown_sha: ~ 4 | articles: {} 5 | last_built: 2021-11-18T21:15Z 6 | urls: 7 | reference: http://svmiller.com/reference 8 | article: http://svmiller.com/articles 9 | 10 | -------------------------------------------------------------------------------- /docs/reference/Rplot001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svmiller/steveproj/a72bd319383ec4fc579b89b4755516b8ecfc38a0/docs/reference/Rplot001.png -------------------------------------------------------------------------------- /docs/reference/create_appendix.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Create an Appendix File for Your Academic Project — create_appendix • steveproj 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 59 | 60 | 61 | 62 | 63 | 64 | 65 |
    66 |
    67 | 106 | 107 | 108 | 109 |
    110 | 111 |
    112 |
    113 | 118 | 119 |
    120 |

    create_appendix() creates an R Markdown for an appendix 121 | to go with your academic project.

    122 |
    123 | 124 |
    create_appendix(path)
    125 | 126 |

    Arguments

    127 | 128 | 129 | 130 | 131 | 138 | 139 |
    path

    a path in which to place the appendix file. Defaults to current 132 | working directory in the absence of a user-specified argument. User-supplied 133 | arguments here should be understood as subdirectories relative to current 134 | working directory. Assume that the current working directory is something 135 | like /home/steve/, then specifying a path of "Documents" in this argument 136 | would create the memo file in /home/steve/Documents. Just be mindful about 137 | your setup if you experiment with this argument.

    140 | 141 |

    Value

    142 | 143 |

    create_appendix() creates a appendix.Rmd file in the path 144 | requested by user. Users can create an appendix at any time during the 145 | submission timeline of the academic project, but I often---but not 146 | always---create them at the revise-and-resubmit phase. That would explain 147 | why it's not a default file.

    148 | 149 |

    Examples

    150 |
    151 | if (FALSE) { 152 | # Creates a `appendix.Rmd` file in working directory 153 | create_appendix() 154 | 155 | # Creates a `appendix.Rmd` in subdirectory of working directory 156 | 157 | create_appendix("subdirectory") 158 | } 159 | 160 |
    161 |
    162 | 167 |
    168 | 169 | 170 |
    171 | 174 | 175 |
    176 |

    Site built with pkgdown 1.6.1.

    177 |
    178 | 179 |
    180 |
    181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | -------------------------------------------------------------------------------- /docs/reference/create_memo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Create a Memo File for Your Academic Project — create_memo • steveproj 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 59 | 60 | 61 | 62 | 63 | 64 | 65 |
    66 |
    67 | 106 | 107 | 108 | 109 |
    110 | 111 |
    112 |
    113 | 118 | 119 |
    120 |

    create_memo() creates an R Markdown for a memo to go 121 | with your academic project.

    122 |
    123 | 124 |
    create_memo(path)
    125 | 126 |

    Arguments

    127 | 128 | 129 | 130 | 131 | 138 | 139 |
    path

    a path in which to place the memo file. Defaults to current 132 | working directory in the absence of a user-specified argument. User-supplied 133 | arguments here should be understood as subdirectories relative to current 134 | working directory. Assume that the current working directory is something 135 | like /home/steve/, then specifying a path of "Documents" in this argument 136 | would create the memo file in /home/steve/Documents. Just be mindful about 137 | your setup if you experiment with this argument.

    140 | 141 |

    Value

    142 | 143 |

    create_memo() creates a memo.Rmd file in the path 144 | requested by user. Users can create a memo at any time during the submission 145 | timeline of the academic project, but I think of these documents as 146 | typically something a user writes when offered an opportunity to revise and 147 | resubmit a manuscript. That would explain why the skeleton file is 148 | structured the way it is.

    149 | 150 |

    Examples

    151 |
    152 | if (FALSE) { 153 | # Creates a `memo.Rmd` file in working directory 154 | create_memo() 155 | 156 | # Creates a `memo.Rmd` in subdirectory of working directory 157 | 158 | create_memo("subdirectory") 159 | } 160 | 161 |
    162 |
    163 | 168 |
    169 | 170 | 171 |
    172 | 175 | 176 |
    177 |

    Site built with pkgdown 1.6.1.

    178 |
    179 | 180 |
    181 |
    182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | -------------------------------------------------------------------------------- /docs/reference/create_project.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Create an Academic Project/Paper Project — create_project • steveproj 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 59 | 60 | 61 | 62 | 63 | 64 | 65 |
    66 |
    67 | 106 | 107 | 108 | 109 |
    110 | 111 |
    112 |
    113 | 118 | 119 |
    120 |

    create_project() provides a convenient function for creating 121 | a new academic/paper project.

    122 |
    123 | 124 |
    create_project(path, ...)
    125 | 126 |

    Arguments

    127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 |
    path

    the directory name for the project (e.g. "my-project", "dissertation", or whatever)

    ...

    optional stuff, but you can ignore this

    138 | 139 |

    Value

    140 | 141 |

    create_project() creates a directory named with whatever is supplied in the path variable. This 142 | directory will appear in the current working directory if it is executed in the command line. The contents of that 143 | directory will include a skeleton project to get the user started. The user can (and must) ultimately make it their own.

    144 | 145 |

    Examples

    146 |
    147 | if (FALSE) { 148 | create_project("example") 149 | create_project("dissertation") 150 | } 151 | 152 |
    153 |
    154 | 159 |
    160 | 161 | 162 |
    163 | 166 | 167 |
    168 |

    Site built with pkgdown 1.6.1.

    169 |
    170 | 171 |
    172 |
    173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | -------------------------------------------------------------------------------- /docs/reference/create_rproj.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Create an R Project File in your Academic Project — create_rproj • steveproj 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 59 | 60 | 61 | 62 | 63 | 64 | 65 |
    66 |
    67 | 106 | 107 | 108 | 109 |
    110 | 111 |
    112 |
    113 | 118 | 119 |
    120 |

    create_rproj() finishes by way of command line what Rstudio will do 121 | naturally. It will add a simple .Rproj file to your directory.

    122 |
    123 | 124 |
    create_rproj(path, ...)
    125 | 126 |

    Arguments

    127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 |
    path

    the directory name for the project (e.g. "my-project", "dissertation", or whatever)

    ...

    optional stuff, but you can ignore this

    138 | 139 |

    Value

    140 | 141 |

    create_rproj() creates an .Rproj file in your directory. It should be run 142 | in the command line after running create_project{} in the command line. You will NOT 143 | need to do this if you elect to use Rstudio's interface for the creation of a project. Rstudio 144 | will do that for you automatically.

    145 | 146 |

    Examples

    147 |
    148 | if (FALSE) { 149 | create_project("example") # creates new directory 150 | create_rproj("example") # creates new \code{.Rproj} file in that directory 151 | } 152 | 153 |
    154 |
    155 | 160 |
    161 | 162 | 163 |
    164 | 167 | 168 |
    169 |

    Site built with pkgdown 1.6.1.

    170 |
    171 | 172 |
    173 |
    174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | -------------------------------------------------------------------------------- /docs/reference/dl_csl.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Download Citation Style Language (CSL) File from Github — dl_csl • steveproj 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 59 | 60 | 61 | 62 | 63 | 64 | 65 |
    66 |
    67 | 106 | 107 | 108 | 109 |
    110 | 111 |
    112 |
    113 | 118 | 119 |
    120 |

    dl_csl() will download a requested citation style language (CSL) file from the 121 | Github repository of CSL files.

    122 |
    123 | 124 |
    dl_csl(csl, dir = "inst")
    125 | 126 |

    Arguments

    127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 137 | 138 |
    csl

    a valid CSL file on the GIthub repository of CSL files, with or without file extension

    dir

    the subdirectory in the working directory in which you want the CSL file, defaults to "inst". A user who wants 136 | the CSL file in their current working directory should set this to be NULL.

    139 | 140 |

    Value

    141 | 142 |

    dl_csl() takes a requested CSL file (from the Github repository) and an optional subdirectory, 143 | downloads the CSL file, and sticks it in the requested directory.

    144 |

    Details

    145 | 146 |

    dl_csl() assumes an active internet connection. The function also builds in a few implicit defaults. 147 | If a file matching the requested CSL exists, the function does nothing. If the requested CSL does not have a ".csl" 148 | extension, the function assumes you forgot it and adds it for you. By default, the function downloads the CSL file 149 | and sticks it in your "inst" folder in the working directory. You can change this if you'd like with the dir 150 | argument. If the directory does not exist, the function creates it for you. If you'd like the CSL file in the current 151 | directory, set the dir argument to be NULL. The Github repository of CSL files is available here: 152 | https://github.com/citation-style-language/styles.

    153 | 154 |

    Examples

    155 |
    156 | if (FALSE) { 157 | dl_csl("american-political-science-association.csl") 158 | # ^ Works, has extension too 159 | dl_csl("journal-of-peace-research") 160 | # ^ Will also work, but message you that it assumes you forgot ".csl" 161 | } 162 | 163 |
    164 |
    165 | 170 |
    171 | 172 | 173 |
    174 | 177 | 178 |
    179 |

    Site built with pkgdown 1.6.1.

    180 |
    181 | 182 |
    183 |
    184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /docs/reference/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Function reference • steveproj 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
    64 |
    65 | 104 | 105 | 106 | 107 |
    108 | 109 |
    110 |
    111 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 140 | 141 | 142 | 143 | 146 | 147 | 148 | 149 | 152 | 153 | 154 | 155 | 158 | 159 | 160 | 161 | 164 | 165 | 166 | 167 | 170 | 171 | 172 | 173 | 176 | 177 | 178 | 179 | 182 | 183 | 184 | 185 |
    126 |

    All functions

    127 |

    128 |
    138 |

    create_appendix()

    139 |

    Create an Appendix File for Your Academic Project

    144 |

    create_memo()

    145 |

    Create a Memo File for Your Academic Project

    150 |

    create_project()

    151 |

    Create an Academic Project/Paper Project

    156 |

    create_rproj()

    157 |

    Create an R Project File in your Academic Project

    162 |

    dl_csl()

    163 |

    Download Citation Style Language (CSL) File from Github

    168 |

    render_appendix()

    169 |

    Render Your R Markdown Appendix to Various Outputs

    174 |

    render_memo()

    175 |

    Render Your R Markdown Memo to Various Outputs

    180 |

    render_ms()

    181 |

    Render Your R Markdown Manuscript to Various Outputs

    186 |
    187 | 188 | 193 |
    194 | 195 | 196 |
    197 | 200 | 201 |
    202 |

    Site built with pkgdown 1.6.1.

    203 |
    204 | 205 |
    206 |
    207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | -------------------------------------------------------------------------------- /docs/reference/render_appendix.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Render Your R Markdown Appendix to Various Outputs — render_appendix • steveproj 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |
    67 |
    68 | 107 | 108 | 109 | 110 |
    111 | 112 |
    113 |
    114 | 119 | 120 |
    121 |

    render_appendix() takes various arguments, most effectively built 122 | into the function, and renders your R Markdown manuscript to various outputs 123 | supported by stevetemplates.

    124 |
    125 | 126 |
    render_appendix(
    127 |   file = "appendix.Rmd",
    128 |   output_dir = "doc",
    129 |   outputs = c("pdf", "pdf-anon"),
    130 |   parameters,
    131 |   latex_engine = "xelatex",
    132 |   dev = "cairo_pdf"
    133 | )
    134 | 135 |

    Arguments

    136 | 137 | 138 | 139 | 140 | 142 | 143 | 144 | 145 | 150 | 151 | 152 | 153 | 157 | 158 | 159 | 160 | 170 | 171 | 172 | 173 | 176 | 177 | 178 | 179 | 181 | 182 |
    file

    the name of the R Markdown file containing that is your 141 | appendix. Defaults to "appendix.Rmd".

    output_dir

    the output directory to contain the formatted manuscript. 146 | Defaults to "doc". Optimally, this is a subdirectory of the directory 147 | containing the manuscript. A user who wants the formatted manuscript 148 | to be in the same directory as the R Markdown file should specify 149 | output_dir = NULL here.

    outputs

    the various formatted manuscript types the user wants, 154 | supplied as a character vector. Must be one or more of "pdf", "pdf-anon", 155 | "word", and/or "html". No other formats are supported right now. Defaults 156 | are "pdf" and "pdf-anon".

    parameters

    optional parameters, specified as a character, based on 161 | what's in your R Markdown file, passed as params in the render() 162 | function in R Markdown. If no parameters are specified here, the 163 | function defaults these parameters to 164 | anonymous=TRUE, doublespacing=TRUE, 165 | which is then wrapped in a list to be passed to the params 166 | argument in render(). Do note this primarily concerns the anonymous 167 | manuscript type. These are somewhat advanced-level arguments, so the user 168 | should be careful what they do here and should have a firm idea what 169 | they are doing here.

    latex_engine

    the LaTeX engine the user may want to use. 174 | Defaults to "xelatex". You can overwrite this if you would like, but 175 | why would you?

    dev

    the graphics device for LaTeX PDFs. Defaults to "cairo_pdf". 180 | You can overwrite this, but why would you?

    183 | 184 |

    Value

    185 | 186 |

    render_ms() takes various arguments, most effectively built 187 | into the function, and renders your R Markdown manuscript to various outputs 188 | supported by stevetemplates.

    189 | 190 |

    Examples

    191 |
    192 | if (FALSE) { 193 | render_appendix() 194 | } 195 | 196 |
    197 |
    198 | 203 |
    204 | 205 | 206 |
    207 | 210 | 211 |
    212 |

    Site built with pkgdown 1.6.1.

    213 |
    214 | 215 |
    216 |
    217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | -------------------------------------------------------------------------------- /docs/reference/render_memo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Render Your R Markdown Memo to Various Outputs — render_memo • steveproj 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |
    67 |
    68 | 107 | 108 | 109 | 110 |
    111 | 112 |
    113 |
    114 | 119 | 120 |
    121 |

    render_memo() takes various arguments, most effectively built 122 | into the function, and renders your R Markdown memo to various outputs 123 | supported by stevetemplates.

    124 |
    125 | 126 |
    render_memo(
    127 |   file = "memo.Rmd",
    128 |   output_dir = "doc",
    129 |   outputs = c("pdf", "word"),
    130 |   latex_engine = "xelatex",
    131 |   dev = "cairo_pdf"
    132 | )
    133 | 134 |

    Arguments

    135 | 136 | 137 | 138 | 139 | 141 | 142 | 143 | 144 | 149 | 150 | 151 | 152 | 155 | 156 | 157 | 158 | 161 | 162 | 163 | 164 | 166 | 167 |
    file

    the name of the R Markdown file containing that is your 140 | memo Defaults to "memo.Rmd".

    output_dir

    the output directory to contain the formatted manuscript. 145 | Defaults to "doc". Optimally, this is a subdirectory of the directory 146 | containing the manuscript. A user who wants the formatted manuscript 147 | to be in the same directory as the R Markdown file should specify 148 | output_dir = NULL here.

    outputs

    the various formatted manuscript types the user wants, 153 | supplied as a character vector. Must be one or more of "pdf" and/or "word". 154 | No other formats are supported right now.

    latex_engine

    the LaTeX engine the user may want to use. 159 | Defaults to "xelatex". You can overwrite this if you would like, but 160 | why would you?

    dev

    the graphics device for LaTeX PDFs. Defaults to "cairo_pdf". 165 | You can overwrite this, but why would you?

    168 | 169 |

    Value

    170 | 171 |

    render_memo() takes various arguments, most effectively built 172 | into the function, and renders your R Markdown memo to various outputs 173 | supported by stevetemplates.

    174 | 175 |

    Examples

    176 |
    177 | if (FALSE) { 178 | render_memo() 179 | } 180 | 181 |
    182 |
    183 | 188 |
    189 | 190 | 191 |
    192 | 195 | 196 |
    197 |

    Site built with pkgdown 1.6.1.

    198 |
    199 | 200 |
    201 |
    202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | -------------------------------------------------------------------------------- /docs/reference/render_ms.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Render Your R Markdown Manuscript to Various Outputs — render_ms • steveproj 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |
    67 |
    68 | 107 | 108 | 109 | 110 |
    111 | 112 |
    113 |
    114 | 119 | 120 |
    121 |

    render_ms() takes various arguments, most effectively built 122 | into the function, and renders your R Markdown manuscript to various outputs 123 | supported by stevetemplates.

    124 |
    125 | 126 |
    render_ms(
    127 |   file = "ms.Rmd",
    128 |   output_dir = "doc",
    129 |   outputs = c("pdf", "pdf-anon", "word", "html"),
    130 |   parameters,
    131 |   latex_engine = "xelatex",
    132 |   dev = "cairo_pdf"
    133 | )
    134 | 135 |

    Arguments

    136 | 137 | 138 | 139 | 140 | 142 | 143 | 144 | 145 | 150 | 151 | 152 | 153 | 156 | 157 | 158 | 159 | 169 | 170 | 171 | 172 | 175 | 176 | 177 | 178 | 180 | 181 |
    file

    the name of the R Markdown file containing that is your 141 | manuscript. Defaults to "ms.Rmd".

    output_dir

    the output directory to contain the formatted manuscript. 146 | Defaults to "doc". Optimally, this is a subdirectory of the directory 147 | containing the manuscript. A user who wants the formatted manuscript 148 | to be in the same directory as the R Markdown file should specify 149 | output_dir = NULL here.

    outputs

    the various formatted manuscript types the user wants, 154 | supplied as a character vector. Must be one or more of "pdf", "pdf-anon", 155 | "word", and/or "html". No other formats are supported right now.

    parameters

    optional parameters, specified as a character, based on 160 | what's in your R Markdown file, passed as params in the render() 161 | function in R Markdown. If no parameters are specified here, the 162 | function defaults these parameters to 163 | anonymous=TRUE, doublespacing=TRUE, removetitleabstract=TRUE, 164 | which is then wrapped in a list to be passed to the params 165 | argument in render(). Do note this primarily concerns the anonymous 166 | manuscript type. These are somewhat advanced-level arguments, so the user 167 | should be careful what they do here and should have a firm idea what 168 | they are doing here.

    latex_engine

    the LaTeX engine the user may want to use. 173 | Defaults to "xelatex". You can overwrite this if you would like, but 174 | why would you?

    dev

    the graphics device for LaTeX PDFs. Defaults to "cairo_pdf". 179 | You can overwrite this, but why would you?

    182 | 183 |

    Value

    184 | 185 |

    render_ms() takes various arguments, most effectively built 186 | into the function, and renders your R Markdown manuscript to various outputs 187 | supported by stevetemplates.

    188 | 189 |

    Examples

    190 |
    191 | if (FALSE) { 192 | render_ms() 193 | } 194 | 195 |
    196 |
    197 | 202 |
    203 | 204 | 205 |
    206 | 209 | 210 |
    211 |

    Site built with pkgdown 1.6.1.

    212 |
    213 | 214 |
    215 |
    216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | -------------------------------------------------------------------------------- /docs/sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | http://svmiller.com/index.html 5 | 6 | 7 | http://svmiller.com/reference/create_appendix.html 8 | 9 | 10 | http://svmiller.com/reference/create_memo.html 11 | 12 | 13 | http://svmiller.com/reference/create_project.html 14 | 15 | 16 | http://svmiller.com/reference/create_rproj.html 17 | 18 | 19 | http://svmiller.com/reference/dl_csl.html 20 | 21 | 22 | http://svmiller.com/reference/render_appendix.html 23 | 24 | 25 | http://svmiller.com/reference/render_memo.html 26 | 27 | 28 | http://svmiller.com/reference/render_ms.html 29 | 30 | 31 | -------------------------------------------------------------------------------- /inst/README/steveproj-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svmiller/steveproj/a72bd319383ec4fc579b89b4755516b8ecfc38a0/inst/README/steveproj-1.png -------------------------------------------------------------------------------- /inst/README/steveproj-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svmiller/steveproj/a72bd319383ec4fc579b89b4755516b8ecfc38a0/inst/README/steveproj-2.png -------------------------------------------------------------------------------- /inst/README/steveproj-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svmiller/steveproj/a72bd319383ec4fc579b89b4755516b8ecfc38a0/inst/README/steveproj-3.png -------------------------------------------------------------------------------- /inst/other_docs/appendix.Rmd: -------------------------------------------------------------------------------- 1 | 2 | ```{r setup, include=FALSE} 3 | is_docx <- knitr::pandoc_to("docx") 4 | is_latex <- knitr::pandoc_to("latex") 5 | 6 | table_format <- ifelse(is_docx, "huxtable", 'default') 7 | 8 | # I don't know how Texas Instruments smart this is, but p-sure default DPI is 96. 9 | # That's not a problem for LaTeX, but it looks not-so-great for Word. 10 | # For Word, let's up that to 600. This should allow for cross-referencing 11 | # in {bookdown} while allowing for conditional DPI 12 | 13 | if (is_latex) { 14 | conditional_dpi <- 96 15 | return(conditional_dpi) 16 | } else { 17 | conditional_dpi <- 600 18 | return(conditional_dpi) 19 | } 20 | 21 | knitr::opts_chunk$set(echo = FALSE, 22 | message=FALSE, warning=FALSE, 23 | fig.path='doc/figs/', 24 | cache.path = 'doc/_cache/', 25 | fig.width = 8.5, dpi = conditional_dpi, 26 | fig.process = function(x) { 27 | x2 = sub('-\\d+([.][a-z]+)$', '\\1', x) 28 | x2 = paste0(stringr::str_extract(x2, '.*/'), 29 | "appendix-", 30 | stringr::str_remove(x2, ".*/")) 31 | if (file.rename(x, x2)) x2 else x 32 | }) 33 | 34 | options(knitr.kable.NA = '') 35 | ``` 36 | 37 | \tableofcontents 38 | \newpage 39 | 40 | 41 | # You Can Start Putting Stuff Here 42 | 43 | Hi Mom! 44 | 45 | # References 46 | 47 | \setlength{\parskip}{6pt} 48 | -------------------------------------------------------------------------------- /inst/other_docs/memo.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | geometry: margin=1in 3 | header-includes: 4 | - \linespread{1.05} 5 | 6 | author: " " 7 | address: "" 8 | email: "" 9 | url: "" 10 | phone: "" 11 | fontsize: 11pt 12 | # mainfont: cochineal 13 | # monofont: Fira Code 14 | 15 | date: "`r format(Sys.time(), '%e %B %Y')`" 16 | greetings: "Dear Editor and Reviewers," 17 | # bibliography: "`r paste0(Sys.getenv('HOME'),'/Dropbox/master.bib')`" 18 | # biblio-style: apsr 19 | --- 20 | 21 | ```{r setup, include=F} 22 | knitr::opts_chunk$set( 23 | collapse = TRUE, 24 | comment = "#>" 25 | ) 26 | 27 | library(tidyverse) 28 | library(peacesciencer) 29 | library(kableExtra) 30 | 31 | is_docx <- knitr::pandoc_to("docx") 32 | is_latex <- knitr::pandoc_to("latex") 33 | is_html <- knitr::pandoc_to("html") 34 | 35 | ``` 36 | 37 | 38 | 39 | I thank you all for the opportunity to submit revisions of my manuscript "[INSERT YOUR MANUSCRIPT NAME HERE]" for possible inclusion in *INSERT JOURNAL HERE*. I thank the [two/three/four/five/six/seven/eight] reviewers and the editorial team for the helpful comments as well. In what follows, I address the editor about the changes to the manuscript that came in light of reviewer feedback. Thereafter, I address the reviewers' comments individually. 40 | 41 | # Comments to the Editorial Team 42 | 43 | Do you ever feel like a plastic bag? Drifting through the wind, wanting to start again? 44 | 45 | Best regards, 46 | 47 | 48 | The Author 49 | 50 | \newpage 51 | 52 | # Reviewer #1's Comments 53 | 54 | Reviewer #1 (R1) said some things. I said some things. We all agreed to move past it. 55 | 56 | # Reviewer #2's Comments 57 | 58 | I thank Reviewer #2 (R2) for their comments. R2 felt I was [2 legit 2 quit](https://www.youtube.com/watch?v=HFCv86Olk8E). That was a very sweet thing for R2 to say and I thank them for it. 59 | -------------------------------------------------------------------------------- /inst/rproj/rename-this.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace,vignette 22 | -------------------------------------------------------------------------------- /inst/rstudio/templates/project/create_project.dcf: -------------------------------------------------------------------------------- 1 | Binding: create_project 2 | Title: Academic Paper/Project using {steveproj} 3 | OpenFiles: README.md 4 | # In the project you can also add icons (the icon should be a PNG, smaller than 64kb 5 | # and in the inst/rstudio/templates folder 6 | Icon: icon-44.png 7 | # Parameter: check 8 | # Widget: CheckboxInput 9 | # Label: Checkbox Input 10 | # Default: On 11 | # Position: left 12 | 13 | # Parameter: select 14 | # Widget: SelectInput 15 | # Label: Select Input 16 | # Fields: Field A, Field B, Field C 17 | # Default: Field B 18 | # Position: left 19 | 20 | # Parameter: text 21 | # Widget: TextInput 22 | # Label: Text Input 23 | # Default: Hello, world! 24 | # Position: right 25 | # 26 | # Parameter: file 27 | # Widget: FileInput 28 | # Label: File Input 29 | # Default: ~/ 30 | # Position: right 31 | -------------------------------------------------------------------------------- /inst/rstudio/templates/project/icon-44.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/svmiller/steveproj/a72bd319383ec4fc579b89b4755516b8ecfc38a0/inst/rstudio/templates/project/icon-44.png -------------------------------------------------------------------------------- /inst/skeleton/.gitattributes: -------------------------------------------------------------------------------- 1 | # Basic .gitattributes for a R repo. 2 | 3 | # Source files 4 | # ============ 5 | *.Rdata binary 6 | *.RData binary 7 | *.rda binary 8 | *.rdb binary 9 | *.rds binary 10 | *.Rd text 11 | *.Rdx binary 12 | *.Rmd text 13 | *.R text 14 | *.Rproj text 15 | *.jpg binary 16 | *.gif binary 17 | *.png binary 18 | *.RDA binary 19 | *.RDS binary 20 | -------------------------------------------------------------------------------- /inst/skeleton/Makefile: -------------------------------------------------------------------------------- 1 | # Specify a fvew variables to avoid repitition downstream 2 | 3 | OUTPUTS=doc/ms.pdf doc/ms-anon.pdf doc/ms.docx doc/ms.html doc/abstract.pdf 4 | RDS= data/Sims.rds data/Mods.rds data/Data.rds 5 | 6 | # Specify the primary targets: the outputs 7 | # Also have a clean option for testing 8 | 9 | all: $(OUTPUTS) 10 | refs: inst/refs.bib 11 | 12 | clean: 13 | rm -rf doc/* data/* 14 | 15 | .PHONY: clean 16 | 17 | # Specialty sourcing for each output 18 | 19 | doc/ms.pdf: ms.Rmd $(RDS) 20 | Rscript -e 'source("src/render_pdf.R")' 21 | 22 | doc/ms-anon.pdf: ms.Rmd $(RDS) 23 | Rscript -e 'source("src/render_pdf-anon.R")' 24 | 25 | doc/ms.docx: ms.Rmd $(RDS) 26 | Rscript -e 'source("src/render_docx.R")' 27 | 28 | doc/ms.html: ms.Rmd 29 | Rscript -e 'source("src/render_html.R")' 30 | 31 | doc/abstract.pdf: ms.Rmd 32 | Rscript -e 'source("src/render_abstract.R")' 33 | 34 | inst/refs.bib: ms.Rmd 35 | Rscript -e 'source("src/get_citations.R")' 36 | 37 | # Specify what to do for each target .rds 38 | 39 | data/Sims.rds: data/Mods.rds R/3-sims.R 40 | Rscript -e 'source("R/3-sims.R")' 41 | 42 | data/Mods.rds: data/Data.rds R/2-analysis.R 43 | Rscript -e 'source("R/2-analysis.R")' 44 | 45 | data/Data.rds: R/1-prep.R 46 | Rscript -e 'source("R/1-prep.R")' 47 | -------------------------------------------------------------------------------- /inst/skeleton/R/1-prep.R: -------------------------------------------------------------------------------- 1 | prep <- function() { 2 | 3 | set.seed(8675309) 4 | ESS9GB %>% 5 | mutate(noise = rnorm(nrow(.))) -> Data 6 | 7 | saveRDS(Data, "data/Data.rds") 8 | Data <<- Data 9 | return(Data) 10 | # #Data 11 | } 12 | -------------------------------------------------------------------------------- /inst/skeleton/R/2-analysis.R: -------------------------------------------------------------------------------- 1 | analysis <- function(data = Data) { 2 | 3 | check_load(formals()) 4 | 5 | Mods <- list() 6 | Mods[[1]] <- lm(immigsent ~ agea + female + eduyrs + uempla + hinctnta + 7 | lrscale, data=Data) 8 | Mods[[2]] <- lm(immigsent ~ agea + female + eduyrs + uempla + hinctnta + 9 | lrscale + noise, data=Data) 10 | 11 | 12 | saveRDS(Mods, "data/Mods.rds") 13 | Mods <<- Mods 14 | return(Mods) 15 | # #Mods 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /inst/skeleton/R/3-qi.R: -------------------------------------------------------------------------------- 1 | qi <- function(data = Data, mods = Mods) { 2 | 3 | check_load(formals()) 4 | 5 | Data %>% 6 | data_grid(lrscale = unique(lrscale), .model = Mods[[1]], 7 | immigsent = 0) %>% na.omit -> newdat 8 | 9 | 10 | QI <- list() 11 | 12 | newdat %>% 13 | # repeat this data frame how many times we did simulations 14 | dplyr::slice(rep(row_number(), 1000)) %>% 15 | bind_cols(get_sims(Mods[[1]], newdata = newdat, 16 | 1000, 8675309), .) -> QI$"SQI (Ideology)" 17 | 18 | saveRDS(QI, "data/QI.rds") 19 | QI <<- QI 20 | return(QI) 21 | } 22 | -------------------------------------------------------------------------------- /inst/skeleton/R/_helpers.R: -------------------------------------------------------------------------------- 1 | check_load <- function(func_formals) { 2 | 3 | aaa <- as.character(func_formals) 4 | 5 | if(all(aaa %in% ls(envir = .GlobalEnv))) { 6 | 7 | print("All formal arguments (i.e. data objects) present and accounted for.") 8 | 9 | } else { 10 | 11 | print("Conditionally loading formal arguments (i.e. data objects).") 12 | 13 | files <- paste0("data/",aaa, ".rds") 14 | 15 | for (i in aaa) { 16 | 17 | filepath <- file.path(paste0("data/",i,".rds")) 18 | assign(i, readRDS(filepath), envir = .GlobalEnv) 19 | 20 | } 21 | } 22 | 23 | } 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /inst/skeleton/R/_render.R: -------------------------------------------------------------------------------- 1 | render_pdf <- function() { 2 | 3 | ymlchars <- file.info("_config.yaml")$size 4 | rmdchars <- file.info("ms.Rmd")$size 5 | 6 | cat(paste0(readChar("_config.yaml",nchars=ymlchars), 7 | readChar("ms.Rmd",nchars=rmdchars)), 8 | file="tmp.Rmd") 9 | 10 | the_output <- "latex" 11 | 12 | rmarkdown::render("tmp.Rmd", 13 | output_file="doc/ms.pdf", 14 | bookdown::pdf_document2(template = stevetemplates::templ_article2(), 15 | latex_engine = "xelatex", dev="cairo_pdf", toc = FALSE, 16 | number_sections = FALSE)) 17 | 18 | delfiles <- dir(pattern="tmp|fff|log|ttt") 19 | file.remove(delfiles) 20 | } 21 | 22 | render_pdfanon <- function() { 23 | 24 | ymlchars <- file.info("_config.yaml")$size 25 | rmdchars <- file.info("ms.Rmd")$size 26 | 27 | cat(paste0(readChar("_config.yaml",nchars=ymlchars), 28 | readChar("ms.Rmd",nchars=rmdchars)), 29 | file="tmp.Rmd") 30 | 31 | the_output <- "latex" 32 | 33 | rmarkdown::render("tmp.Rmd", 34 | output_file="doc/ms-anon.pdf", 35 | params=list(anonymous=TRUE,doublespacing=TRUE,removetitleabstract=TRUE), 36 | bookdown::pdf_document2(template = stevetemplates::templ_article2(), 37 | latex_engine = "xelatex", dev="cairo_pdf", toc = FALSE, 38 | number_sections = FALSE)) 39 | 40 | delfiles <- dir(pattern="tmp|fff|log|ttt") 41 | file.remove(delfiles) 42 | } 43 | 44 | 45 | render_docx <- function() { 46 | 47 | ymlchars <- file.info("_config.yaml")$size 48 | rmdchars <- file.info("ms.Rmd")$size 49 | 50 | cat(paste0(readChar("_config.yaml",nchars=ymlchars), 51 | readChar("ms.Rmd",nchars=rmdchars)), 52 | file="tmp.Rmd") 53 | 54 | the_output <- "word" 55 | 56 | rmarkdown::render("tmp.Rmd", output_file="doc/ms.docx", 57 | rmarkdown::word_document(reference_docx = stevetemplates::templ_word())) 58 | 59 | delfiles <- dir(pattern="tmp|fff|log|ttt") 60 | file.remove(delfiles) 61 | } 62 | 63 | # render_presentation <- function() { 64 | # 65 | # rmarkdown::render("presentation.Rmd", 66 | # output_file="doc/presentation.pdf", 67 | # rmarkdown::beamer_presentation(template = stevetemplates::templ_beamer(), 68 | # latex_engine = "xelatex", dev="cairo_pdf", toc = FALSE, 69 | # number_sections = FALSE, 70 | # theme = "metropolis")) 71 | # 72 | # } 73 | -------------------------------------------------------------------------------- /inst/skeleton/README.md: -------------------------------------------------------------------------------- 1 | # A README for This Project 2 | 3 | Thank you for choosing [`{steveproj}`](https://github.com/svmiller/steveproj) for your academic paper/project in the R programming language. You had many options to select to assist you in your research, and you selected this template from a hopelessly vain and self-interested political scientist. No matter the vanity and weirdness of its creator, this package should do well to facilitate your research around the R programming language in an intuitive, flexible, and reproducible way.[*] 4 | 5 | 6 | [*]: [`{steveproj}`](https://github.com/svmiller/steveproj) comes with everything you see here. Batteries not included. Warning: pregnant women, the elderly, and children under 10 should avoid prolonged exposure to `{steveproj}`. Do not taunt `{steveproj}`. Seriously. Sign this waiver. 7 | -------------------------------------------------------------------------------- /inst/skeleton/_config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Sagan Ipsum and a Workflow Guide with Make, R, R Markdown, and Some {stevetemplates}" 3 | author: 4 | - affiliation: "Cornell University" 5 | name: "Carl Sagan" 6 | - affiliation: "Stockholm University" 7 | name: "Steven V. Miller" 8 | # bibliography: "`r paste0(Sys.getenv('HOME'),'/Dropbox/master.bib')`" # This would be more general 9 | bibliography: inst/refs.bib 10 | abstract: | 11 | Gathered by gravity rings of Uranus finite but unbounded extraordinary claims require 12 | extraordinary evidence permanence of the stars white dwarf. A mote of dust suspended 13 | in a sunbeam invent the universe rich in heavy atoms hearts of the stars vastness is 14 | bearable only through love at the edge of forever. Something incredible is waiting to be 15 | known descended from astronomers bits of moving fluff vanquish the impossible with pretty 16 | stories for which there's little good evidence a very small stage in a vast cosmic arena 17 | and billions upon billions upon billions upon billions upon billions upon billions upon billions. 18 | keywords: "R Markdown, R, Make, {stevetemplates}, the Cosmos, billions and billions" 19 | thanks: | 20 | Replication files are available on the author's Github account 21 | (http://github.com/svmiller/svm-r-markdown-templates). 22 | **Current version**: `r format(Sys.time(), '%B %d, %Y')`; 23 | **Corresponding author**: steven.v.miller@gmail.com. Carl Sagan has regrettably 24 | not been with us for 25 years and this tutorial is so beneath someone of his stature. 25 | geometry: margin=1in 26 | mainfont: cochineal 27 | #sansfont: Linux Biolinum O 28 | fontsize: 11pt 29 | endnote: no 30 | # pandocparas: TRUE 31 | sansitup: FALSE 32 | params: 33 | anonymous: "" 34 | doublespacing: "" 35 | removetitleabstract: "" 36 | anonymous: '`r params$anonymous`' 37 | doublespacing: '`r params$doublespacing`' 38 | removetitleabstract: '`r params$removetitleabstract`' 39 | header-includes: 40 | - \usepackage{longtable} 41 | - \LTcapwidth=.95\textwidth 42 | - \linespread{1.05} 43 | - \usepackage{hyperref} 44 | --- 45 | -------------------------------------------------------------------------------- /inst/skeleton/_output.yaml: -------------------------------------------------------------------------------- 1 | knit: stop('\n\nDon\'t knit with the "Knit" button in RStudio.\nUse RStudio\'s Terminal panel instead. Do something like "make all" or "make clean" for creating documents.\n\n') 2 | -------------------------------------------------------------------------------- /inst/skeleton/_targets.R: -------------------------------------------------------------------------------- 1 | library(targets) # load {targets} 2 | sapply(list.files("R", full.names=TRUE), source) # load everything in R/ dir. 3 | tar_option_set(packages = c("stevedata", "tidyverse", "modelr", "stevemisc"), 4 | tidy_eval = TRUE) 5 | # ^ declare all packages needed to do my analysis 6 | # Specify workflow below 7 | list( 8 | tar_target(Data, { 9 | prep() 10 | }), # Finished data (Data) depends on prep() 11 | tar_target(Mods, { # Regression models (Mods) depend on Data, analysis() 12 | analysis(Data) 13 | Data 14 | }), 15 | tar_target(QI, { # QIs depend on Mods, Data, and qi() function 16 | Mods 17 | Data 18 | qi(Data, Mods) 19 | }), 20 | # Next two are flat files (for the documents) and not functions or R objects. 21 | tar_target(ms_rmd, "ms.Rmd", format = "file"), 22 | tar_target(ms_yaml, "_config.yaml", format = "file"), 23 | # Finally: docs is an amalgam of outputs, depending on just about everything. 24 | tar_target(docs, {Data # if data change, documents should change. 25 | Mods # if models change, documents should change. 26 | QI # if QIs change, documents should change 27 | ms_rmd # if the (R Markdown) document should change, final docs should change 28 | ms_yaml # if document preamble changes, final docs should change 29 | render_pdf() # function to create nice, pretty PDF (in {stevetemplates}) 30 | render_pdfanon() # function to create anon. PDF (in {stevetemplates}) 31 | render_docx() # function to create Word doc, just in case. 32 | }) 33 | ) 34 | -------------------------------------------------------------------------------- /inst/skeleton/inst/refs.bib: -------------------------------------------------------------------------------- 1 | @Article{miller2018etttc, 2 | Title = {External Territorial Threats and Tolerance of Corruption: A Private/Government Distinction}, 3 | Author = {Steven V. Miller}, 4 | Journal = {Peace Economics, Peace Science and Public Policy}, 5 | Year = {2018}, 6 | Number = {1}, 7 | Volume = {24}, 8 | 9 | Owner = {steve}, 10 | Timestamp = {2018.06.14} 11 | } 12 | 13 | @Article{miller2017etst, 14 | Title = {Economic Threats or Societal Turmoil? Understanding Preferences for Authoritarian Political Systems}, 15 | Author = {Steven V. Miller}, 16 | Journal = {Political Behavior}, 17 | Year = {2017}, 18 | Number = {2}, 19 | Pages = {457--478}, 20 | Volume = {39}, 21 | 22 | Owner = {steve}, 23 | Timestamp = {2016.10.05} 24 | } 25 | 26 | @Article{miller2017ieea, 27 | Title = {Individual-Level Expectations of Executive Authority under Territorial Threat}, 28 | Author = {Steven V. Miller}, 29 | Journal = {Conflict Management and Peace Science}, 30 | Year = {2017}, 31 | Number = {5}, 32 | Pages = {526--545}, 33 | Volume = {34}, 34 | 35 | Owner = {steve}, 36 | Timestamp = {2015.10.13} 37 | } 38 | 39 | @Article{miller2013tdpi, 40 | Title = {Territorial Disputes and the Politics of Individual Well-Being}, 41 | Author = {Steven V. Miller}, 42 | Journal = {Journal of Peace Research}, 43 | Year = {2013}, 44 | Number = {6}, 45 | Pages = {677--690}, 46 | Volume = {50}, 47 | 48 | Owner = {steve}, 49 | Timestamp = {2013.07.25} 50 | } 51 | 52 | 53 | @Article{gibleretal2012iia, 54 | author = {Gibler, Douglas M. and Hutchison, Marc L. and Steven V. Miller}, 55 | title = {Individual Identity Attachments and International Conflict: The Importance of Territorial Threat}, 56 | journal = {Comparative Political Studies}, 57 | year = {2012}, 58 | volume = {45}, 59 | number = {12}, 60 | pages = {1655--1683}, 61 | owner = {steve}, 62 | timestamp = {2012.03.14}, 63 | } 64 | 65 | @Article{giblermiller2014etts, 66 | Title = {External Territorial Threat, State Capacity, and Civil War}, 67 | Author = {Gibler, Douglas M. and Steven V. Miller}, 68 | Journal = {Journal of Peace Research}, 69 | Year = {2014}, 70 | Number = {5}, 71 | Pages = {634--646}, 72 | Volume = {51}, 73 | 74 | Owner = {steve}, 75 | Timestamp = {2014.09.04} 76 | } 77 | 78 | @Article{giblermiller2013qv, 79 | Title = {Quick Victories? Territory, Democracies, and Their Disputes}, 80 | Author = {Douglas M. Gibler and Steven V. Miller}, 81 | Journal = {Journal of Conflict Resolution}, 82 | Year = {2013}, 83 | Number = {2}, 84 | Pages = {258--284}, 85 | Volume = {57}, 86 | 87 | Owner = {steve}, 88 | Timestamp = {2013.01.09} 89 | } 90 | 91 | @Article{giblermiller2012cfap, 92 | Title = {Comparing the Foreign Aid Policies of Presidents Bush and Obama}, 93 | Author = {Douglas M. Gibler and Steven V. Miller}, 94 | Journal = {Social Science Quarterly}, 95 | Year = {2012}, 96 | Number = {5}, 97 | Pages = {1202--1217}, 98 | Volume = {93}, 99 | 100 | Owner = {steve}, 101 | Timestamp = {2015.01.09} 102 | } 103 | 104 | @Article{gibleretal2016amid, 105 | Title = {An Analysis of the {M}ilitarized {I}nterstate {D}ispute {(MID)} Dataset, 1816-2001}, 106 | Author = {Douglas M. Gibler and Steven V. Miller and Erin K. Little}, 107 | Journal = {International Studies Quarterly}, 108 | Year = {2016}, 109 | Number = {4}, 110 | Pages = {719--730}, 111 | Volume = {60}, 112 | 113 | Owner = {steve}, 114 | Timestamp = {2016.04.20} 115 | } 116 | 117 | @Article{millergibler2011dtnc, 118 | Title = {Democracies, Territory and Negotiated Compromises}, 119 | Author = {Miller, Steven V. and Gibler, Douglas M.}, 120 | Journal = {Conflict Management and Peace Science}, 121 | Year = {2011}, 122 | Number = {3}, 123 | Pages = {261--279}, 124 | Volume = {28}, 125 | 126 | Owner = {steve}, 127 | Timestamp = {2010.05.07} 128 | } 129 | 130 | -------------------------------------------------------------------------------- /man/create_appendix.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/create_appendix.R 3 | \name{create_appendix} 4 | \alias{create_appendix} 5 | \title{Create an Appendix File for Your Academic Project} 6 | \usage{ 7 | create_appendix(path) 8 | } 9 | \arguments{ 10 | \item{path}{a path in which to place the appendix file. Defaults to current 11 | working directory in the absence of a user-specified argument. User-supplied 12 | arguments here should be understood as subdirectories relative to current 13 | working directory. Assume that the current working directory is something 14 | like \verb{/home/steve/}, then specifying a path of "Documents" in this argument 15 | would create the memo file in \verb{/home/steve/Documents}. Just be mindful about 16 | your setup if you experiment with this argument.} 17 | } 18 | \value{ 19 | \code{create_appendix()} creates a \code{appendix.Rmd} file in the path 20 | requested by user. Users can create an appendix at any time during the 21 | submission timeline of the academic project, but I often---but not 22 | always---create them at the revise-and-resubmit phase. That would explain 23 | why it's not a default file. 24 | } 25 | \description{ 26 | \code{create_appendix()} creates an R Markdown for an appendix 27 | to go with your academic project. 28 | } 29 | \examples{ 30 | 31 | \dontrun{ 32 | # Creates a `appendix.Rmd` file in working directory 33 | create_appendix() 34 | 35 | # Creates a `appendix.Rmd` in subdirectory of working directory 36 | 37 | create_appendix("subdirectory") 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /man/create_memo.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/create_memo.R 3 | \name{create_memo} 4 | \alias{create_memo} 5 | \title{Create a Memo File for Your Academic Project} 6 | \usage{ 7 | create_memo(path) 8 | } 9 | \arguments{ 10 | \item{path}{a path in which to place the memo file. Defaults to current 11 | working directory in the absence of a user-specified argument. User-supplied 12 | arguments here should be understood as subdirectories relative to current 13 | working directory. Assume that the current working directory is something 14 | like \verb{/home/steve/}, then specifying a path of "Documents" in this argument 15 | would create the memo file in \verb{/home/steve/Documents}. Just be mindful about 16 | your setup if you experiment with this argument.} 17 | } 18 | \value{ 19 | \code{create_memo()} creates a \code{memo.Rmd} file in the path 20 | requested by user. Users can create a memo at any time during the submission 21 | timeline of the academic project, but I think of these documents as 22 | typically something a user writes when offered an opportunity to revise and 23 | resubmit a manuscript. That would explain why the skeleton file is 24 | structured the way it is. 25 | } 26 | \description{ 27 | \code{create_memo()} creates an R Markdown for a memo to go 28 | with your academic project. 29 | } 30 | \examples{ 31 | 32 | \dontrun{ 33 | # Creates a `memo.Rmd` file in working directory 34 | create_memo() 35 | 36 | # Creates a `memo.Rmd` in subdirectory of working directory 37 | 38 | create_memo("subdirectory") 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /man/create_project.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/create_project.R 3 | \name{create_project} 4 | \alias{create_project} 5 | \title{Create an Academic Project/Paper Project} 6 | \usage{ 7 | create_project(path, ...) 8 | } 9 | \arguments{ 10 | \item{path}{the directory name for the project (e.g. "my-project", "dissertation", or whatever)} 11 | 12 | \item{...}{optional stuff, but you can ignore this} 13 | } 14 | \value{ 15 | \code{create_project()} creates a directory named with whatever is supplied in the \code{path} variable. This 16 | directory will appear in the current working directory if it is executed in the command line. The contents of that 17 | directory will include a skeleton project to get the user started. The user can (and must) ultimately make it their own. 18 | } 19 | \description{ 20 | \code{create_project()} provides a convenient function for creating 21 | a new academic/paper project. 22 | } 23 | \examples{ 24 | 25 | \dontrun{ 26 | create_project("example") 27 | create_project("dissertation") 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /man/create_rproj.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/create_rproj.R 3 | \name{create_rproj} 4 | \alias{create_rproj} 5 | \title{Create an R Project File in your Academic Project} 6 | \usage{ 7 | create_rproj(path, ...) 8 | } 9 | \arguments{ 10 | \item{path}{the directory name for the project (e.g. "my-project", "dissertation", or whatever)} 11 | 12 | \item{...}{optional stuff, but you can ignore this} 13 | } 14 | \value{ 15 | \code{create_rproj()} creates an \code{.Rproj} file in your directory. It should be run 16 | in the command line \emph{after} running \code{create_project{}} in the command line. You will NOT 17 | need to do this if you elect to use Rstudio's interface for the creation of a project. Rstudio 18 | will do that for you automatically. 19 | } 20 | \description{ 21 | \code{create_rproj()} finishes by way of command line what Rstudio will do 22 | naturally. It will add a simple \code{.Rproj} file to your directory. 23 | } 24 | \examples{ 25 | 26 | \dontrun{ 27 | create_project("example") # creates new directory 28 | create_rproj("example") # creates new \code{.Rproj} file in that directory 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /man/dl_csl.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/dl_csl.R 3 | \name{dl_csl} 4 | \alias{dl_csl} 5 | \title{Download Citation Style Language (CSL) File from Github} 6 | \usage{ 7 | dl_csl(csl, dir = "inst") 8 | } 9 | \arguments{ 10 | \item{csl}{a valid CSL file on the GIthub repository of CSL files, with or without file extension} 11 | 12 | \item{dir}{the subdirectory in the working directory in which you want the CSL file, defaults to "inst". A user who wants 13 | the CSL file in their current working directory should set this to be \code{NULL}.} 14 | } 15 | \value{ 16 | \code{dl_csl()} takes a requested CSL file (from the Github repository) and an optional subdirectory, 17 | downloads the CSL file, and sticks it in the requested directory. 18 | } 19 | \description{ 20 | \code{dl_csl()} will download a requested citation style language (CSL) file from the 21 | Github repository of CSL files. 22 | } 23 | \details{ 24 | \code{dl_csl()} assumes an active internet connection. The function also builds in a few implicit defaults. 25 | If a file matching the requested CSL exists, the function does nothing. If the requested CSL does not have a ".csl" 26 | extension, the function assumes you forgot it and adds it for you. By default, the function downloads the CSL file 27 | and sticks it in your "inst" folder in the working directory. You can change this if you'd like with the \code{dir} 28 | argument. If the directory does not exist, the function creates it for you. If you'd like the CSL file in the current 29 | directory, set the \code{dir} argument to be \code{NULL}. The Github repository of CSL files is available here: 30 | \url{https://github.com/citation-style-language/styles}. 31 | } 32 | \examples{ 33 | 34 | \dontrun{ 35 | dl_csl("american-political-science-association.csl") 36 | # ^ Works, has extension too 37 | dl_csl("journal-of-peace-research") 38 | # ^ Will also work, but message you that it assumes you forgot ".csl" 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /man/render_appendix.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/render_appendix.R 3 | \name{render_appendix} 4 | \alias{render_appendix} 5 | \title{Render Your R Markdown Appendix to Various Outputs} 6 | \usage{ 7 | render_appendix( 8 | file = "appendix.Rmd", 9 | output_dir = "doc", 10 | outputs = c("pdf", "pdf-anon"), 11 | parameters, 12 | latex_engine = "xelatex", 13 | dev = "cairo_pdf" 14 | ) 15 | } 16 | \arguments{ 17 | \item{file}{the name of the R Markdown file containing that is your 18 | appendix. Defaults to "appendix.Rmd".} 19 | 20 | \item{output_dir}{the output directory to contain the formatted manuscript. 21 | Defaults to "doc". Optimally, this is a subdirectory of the directory 22 | containing the manuscript. A user who wants the formatted manuscript 23 | to be in the same directory as the R Markdown file should specify 24 | \code{output_dir = NULL} here.} 25 | 26 | \item{outputs}{the various formatted manuscript types the user wants, 27 | supplied as a character vector. Must be one or more of "pdf", "pdf-anon", 28 | "word", and/or "html". No other formats are supported right now. Defaults 29 | are "pdf" and "pdf-anon".} 30 | 31 | \item{parameters}{optional parameters, specified as a character, based on 32 | what's in your R Markdown file, passed as \code{params} in the \code{render()} 33 | function in R Markdown. If no parameters are specified here, the 34 | function defaults these parameters to 35 | \verb{anonymous=TRUE, doublespacing=TRUE}, 36 | which is then wrapped in a list to be passed to the \code{params} 37 | argument in \code{render()}. Do note this primarily concerns the anonymous 38 | manuscript type. These are somewhat advanced-level arguments, so the user 39 | should be careful what they do here and should have a firm idea what 40 | they are doing here.} 41 | 42 | \item{latex_engine}{the LaTeX engine the user may want to use. 43 | Defaults to \code{"xelatex"}. You can overwrite this if you would like, but 44 | why would you?} 45 | 46 | \item{dev}{the graphics device for LaTeX PDFs. Defaults to \code{"cairo_pdf"}. 47 | You can overwrite this, but why would you?} 48 | } 49 | \value{ 50 | \code{render_ms()} takes various arguments, most effectively built 51 | into the function, and renders your R Markdown manuscript to various outputs 52 | supported by \pkg{stevetemplates}. 53 | } 54 | \description{ 55 | \code{render_appendix()} takes various arguments, most effectively built 56 | into the function, and renders your R Markdown manuscript to various outputs 57 | supported by \pkg{stevetemplates}. 58 | } 59 | \examples{ 60 | 61 | \dontrun{ 62 | render_appendix() 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /man/render_memo.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/render_memo.R 3 | \name{render_memo} 4 | \alias{render_memo} 5 | \title{Render Your R Markdown Memo to Various Outputs} 6 | \usage{ 7 | render_memo( 8 | file = "memo.Rmd", 9 | output_dir = "doc", 10 | outputs = c("pdf", "word"), 11 | latex_engine = "xelatex", 12 | dev = "cairo_pdf" 13 | ) 14 | } 15 | \arguments{ 16 | \item{file}{the name of the R Markdown file containing that is your 17 | memo Defaults to "memo.Rmd".} 18 | 19 | \item{output_dir}{the output directory to contain the formatted manuscript. 20 | Defaults to "doc". Optimally, this is a subdirectory of the directory 21 | containing the manuscript. A user who wants the formatted manuscript 22 | to be in the same directory as the R Markdown file should specify 23 | \code{output_dir = NULL} here.} 24 | 25 | \item{outputs}{the various formatted manuscript types the user wants, 26 | supplied as a character vector. Must be one or more of "pdf" and/or "word". 27 | No other formats are supported right now.} 28 | 29 | \item{latex_engine}{the LaTeX engine the user may want to use. 30 | Defaults to \code{"xelatex"}. You can overwrite this if you would like, but 31 | why would you?} 32 | 33 | \item{dev}{the graphics device for LaTeX PDFs. Defaults to \code{"cairo_pdf"}. 34 | You can overwrite this, but why would you?} 35 | } 36 | \value{ 37 | \code{render_memo()} takes various arguments, most effectively built 38 | into the function, and renders your R Markdown memo to various outputs 39 | supported by \pkg{stevetemplates}. 40 | } 41 | \description{ 42 | \code{render_memo()} takes various arguments, most effectively built 43 | into the function, and renders your R Markdown memo to various outputs 44 | supported by \pkg{stevetemplates}. 45 | } 46 | \examples{ 47 | 48 | \dontrun{ 49 | render_memo() 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /man/render_ms.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/render_ms.R 3 | \name{render_ms} 4 | \alias{render_ms} 5 | \title{Render Your R Markdown Manuscript to Various Outputs} 6 | \usage{ 7 | render_ms( 8 | file = "ms.Rmd", 9 | output_dir = "doc", 10 | outputs = c("pdf", "pdf-anon", "word", "html"), 11 | parameters, 12 | latex_engine = "xelatex", 13 | dev = "cairo_pdf" 14 | ) 15 | } 16 | \arguments{ 17 | \item{file}{the name of the R Markdown file containing that is your 18 | manuscript. Defaults to "ms.Rmd".} 19 | 20 | \item{output_dir}{the output directory to contain the formatted manuscript. 21 | Defaults to "doc". Optimally, this is a subdirectory of the directory 22 | containing the manuscript. A user who wants the formatted manuscript 23 | to be in the same directory as the R Markdown file should specify 24 | \code{output_dir = NULL} here.} 25 | 26 | \item{outputs}{the various formatted manuscript types the user wants, 27 | supplied as a character vector. Must be one or more of "pdf", "pdf-anon", 28 | "word", and/or "html". No other formats are supported right now.} 29 | 30 | \item{parameters}{optional parameters, specified as a character, based on 31 | what's in your R Markdown file, passed as \code{params} in the \code{render()} 32 | function in R Markdown. If no parameters are specified here, the 33 | function defaults these parameters to 34 | \verb{anonymous=TRUE, doublespacing=TRUE, removetitleabstract=TRUE}, 35 | which is then wrapped in a list to be passed to the \code{params} 36 | argument in \code{render()}. Do note this primarily concerns the anonymous 37 | manuscript type. These are somewhat advanced-level arguments, so the user 38 | should be careful what they do here and should have a firm idea what 39 | they are doing here.} 40 | 41 | \item{latex_engine}{the LaTeX engine the user may want to use. 42 | Defaults to \code{"xelatex"}. You can overwrite this if you would like, but 43 | why would you?} 44 | 45 | \item{dev}{the graphics device for LaTeX PDFs. Defaults to \code{"cairo_pdf"}. 46 | You can overwrite this, but why would you?} 47 | } 48 | \value{ 49 | \code{render_ms()} takes various arguments, most effectively built 50 | into the function, and renders your R Markdown manuscript to various outputs 51 | supported by \pkg{stevetemplates}. 52 | } 53 | \description{ 54 | \code{render_ms()} takes various arguments, most effectively built 55 | into the function, and renders your R Markdown manuscript to various outputs 56 | supported by \pkg{stevetemplates}. 57 | } 58 | \examples{ 59 | 60 | \dontrun{ 61 | render_ms() 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /pkgdown/extra.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i'); 2 | @import url('https://fonts.googleapis.com/css?family=Titillium+Web:300,300i,400,400i,600,600i,700,700i'); 3 | @import url('https://fonts.googleapis.com/css?family=Fira+Code:400'); 4 | 5 | 6 | body { 7 | font-family: 'Open Sans', Helvetica, Arial, sans-serif; 8 | font-size: 11.5pt; 9 | line-height: 1.5; 10 | font-weight: 300; 11 | color: #111111; 12 | } 13 | 14 | h1, h2, h3, h4, h5, h6 { 15 | font-family: 'Titillium Web', serif; 16 | } 17 | 18 | code { 19 | padding: 1px; 20 | background-color: #fff; 21 | font-family: 'Fira Code', monospace; 22 | } 23 | -------------------------------------------------------------------------------- /steveproj.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageCleanBeforeInstall: Yes 21 | PackageInstallArgs: --no-multiarch --with-keep.source 22 | PackageRoxygenize: rd,collate,namespace,vignette 23 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(steveproj) 3 | 4 | test_check("steveproj") 5 | -------------------------------------------------------------------------------- /tests/testthat/test-create_project.R: -------------------------------------------------------------------------------- 1 | test_create_project <- function(...) { 2 | 3 | # don't run on CRAN 4 | # copied from rstudio/rticles, if I'm being honest 5 | if (!identical(Sys.getenv("NOT_CRAN"), "true")) return() 6 | 7 | # work in a temp directory 8 | dir <- tempfile() 9 | dir.create(dir) 10 | oldwd <- setwd(dir) 11 | on.exit(setwd(oldwd), add = TRUE) 12 | 13 | steveproj::create_project("testthis") 14 | 15 | #setwd(paste0(oldwd, "/testthis")) 16 | message(tempdir()) 17 | 18 | expect_true(file.exists(paste0(dir,"/testthis/ms.Rmd"))) 19 | expect_true(file.exists(paste0(dir,"/testthis/Makefile"))) 20 | expect_true(file.exists(paste0(dir,"/testthis/README.md"))) 21 | expect_true(file.exists(paste0(dir,"/testthis/_output.yaml"))) 22 | 23 | expect_true(dir.exists(paste0(dir,"/testthis/doc"))) 24 | expect_true(dir.exists(paste0(dir,"/testthis/inst"))) 25 | expect_true(dir.exists(paste0(dir,"/testthis/data"))) 26 | expect_true(dir.exists(paste0(dir,"/testthis/src"))) 27 | expect_true(dir.exists(paste0(dir,"/testthis/R"))) 28 | 29 | expect_true(file.exists(paste0(dir,"/testthis/src/render_pdf.R"))) 30 | expect_true(file.exists(paste0(dir,"/testthis/src/render_pdf-anon.R"))) 31 | expect_true(file.exists(paste0(dir,"/testthis/src/render_docx.R"))) 32 | expect_true(file.exists(paste0(dir,"/testthis/src/render_abstract.R"))) 33 | expect_true(file.exists(paste0(dir,"/testthis/src/get_citations.R"))) 34 | 35 | expect_true(file.exists(paste0(dir,"/testthis/R/1-prep.R"))) 36 | expect_true(file.exists(paste0(dir,"/testthis/R/2-analysis.R"))) 37 | expect_true(file.exists(paste0(dir,"/testthis/R/3-sims.R"))) 38 | 39 | system("cd testthis; make data/Sims.rds") 40 | 41 | 42 | 43 | # # create a draft of the format 44 | # testdoc <- paste0(templ,".Rmd") 45 | # rmarkdown::draft( 46 | # testdoc, template = templ, package="stevetemplates", 47 | # create_dir = FALSE, edit = FALSE 48 | # ) 49 | # expect_true(file.exists(paste0(templ,".Rmd"))) 50 | # message('Rendering the ', templ, ' format...') 51 | # output_file <- rmarkdown::render(testdoc, quiet = TRUE) 52 | # assert(paste(templ, "format works"), { 53 | # file.exists(output_file) 54 | # }) 55 | } 56 | 57 | test_create_project() 58 | --------------------------------------------------------------------------------