Skip to content

Commit

Permalink
PWB options on template (#63)
Browse files Browse the repository at this point in the history
Co-authored-by: Alan Yeung <[email protected]>
  • Loading branch information
alan-y and alan-y authored Sep 26, 2023
1 parent a3a3caa commit 823096e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion R/new_script.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ new_script <- function() {
r_code <- script_template(author = author)

if (git) {
remove_start <- gregexpr("# Original", r_code)[[1]][1] - 1
remove_start <- gregexpr("# Latest", r_code)[[1]][1] - 1
remove_end <- gregexpr("Latest update description \\(delete if using version control\\)\n", r_code)[[1]]
remove_end <- as.integer(remove_end + attr(remove_end, "match.length"))

Expand Down
2 changes: 1 addition & 1 deletion R/phsproject.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ phsproject <- function(path, author, n_scripts = 1, git = FALSE, renv = FALSE, o
r_code <- script_template(author = author)

if (git) {
remove_start <- gregexpr("# Original", r_code)[[1]][1] - 1
remove_start <- gregexpr("# Latest", r_code)[[1]][1] - 1
remove_end <- gregexpr("Latest update description \\(delete if using version control\\)\n", r_code)[[1]]
remove_end <- as.integer(remove_end + attr(remove_end, "match.length"))

Expand Down
4 changes: 0 additions & 4 deletions R/phstemplates.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@
#' @docType package
#' @name phstemplates
NULL

# Stops notes from appearing in R CMD check because of undefined global
# variables
if (getRversion() >= "2.15.1") utils::globalVariables(c("RStudio.Version"))
13 changes: 7 additions & 6 deletions R/script_template.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
script_template <- function(author = Sys.info()[["user"]]) {
author <- paste("# Original author(s):", author)
orig_date <- paste("# Original date:", Sys.Date())
run_on <- paste0(
"# Written/run on RStudio ", RStudio.Version()$mode, " ",
RStudio.Version()$version, " and R ",
version$major, ".", version$minor
)

r_code <- c(
"##########################################################",
Expand All @@ -17,9 +12,13 @@ script_template <- function(author = Sys.info()[["user"]]) {
"# Latest update date (delete if using version control)",
"# Latest update description (delete if using version control)",
"# Type of script (e.g. extraction, preparation, modelling)",
run_on,
run_on(),
"# Description of content",
"# Approximate run time",
"# ",
"# PWB recommended options #",
"# CPUs: ",
"# Memory: ",
"##########################################################",
"",
"",
Expand All @@ -41,6 +40,8 @@ script_template <- function(author = Sys.info()[["user"]]) {
"### 3 Section Heading ----",
"",
"",
"# quit(save = \"no\") # Uncomment this to automatically close the R session when finished",
"",
"### END OF SCRIPT ###"
)
r_code <- paste(r_code, collapse = "\n")
Expand Down
7 changes: 1 addition & 6 deletions R/shiny_app_template.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@ shiny_app_template <- function(app_name = "WRITE APP NAME HERE",
author = Sys.info()[["user"]]) {
author <- paste("# Original author(s):", author)
orig_date <- paste("# Original date:", Sys.Date())
run_on <- paste0(
"# Written/run on RStudio ", RStudio.Version()$mode, " ",
RStudio.Version()$version, " and R ",
version$major, ".", version$minor
)

r_code <- c(
"##########################################################",
paste0("# ", app_name),
author,
orig_date,
run_on,
run_on(),
"# Description of content",
"##########################################################",
"",
Expand Down

0 comments on commit 823096e

Please sign in to comment.