Title: | A Project Infrastructure for Researchers |
---|---|
Description: | Provides a project infrastructure with a focus on manuscript creation. Creates a project folder with a single command, containing subdirectories for specific components, templates for manuscripts, and so on. |
Authors: | Nik Krieger [aut, cre], Adam Perzynski [aut], Jarrod Dalton [aut] |
Maintainer: | Nik Krieger <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.1.99.9990 |
Built: | 2024-11-03 03:34:47 UTC |
Source: | https://github.com/clevelandclinicqhs/projects |
The projects
package provides a project infrastructure with a focus on
manuscript creation. It creates a project folder with a single command,
containing subdirectories for specific components, templates for manuscripts,
and so on.
There are several functions that require interactive user
confirmation via the console. Since interactive console input is
incompatible with knitting via R Markdown files, the projects
package was coded such that user confirmation is bypassed when
isTRUE(getOption('knitr.in.progress')) == TRUE
. Therefore, all
projects
package functions are usable when knitting. Knit
with caution!
The authors of this package acknowledge the support provided by members of the Northeast Ohio Cohort for Atherosclerotic Risk Estimation (NEOCARE) investigative team: Claudia Coulton, Douglas Gunzler, Darcy Freedman, Neal Dawson, Michael Rothberg, David Zidar, David Kaelber, Douglas Einstadter, Alex Milinovich, Monica Webb Hooper, Kristen Hassmiller-Lich, Ye Tian (Devin), Kristen Berg, and Sandy Andrukat.
This work was supported by The National Institute on Aging of the National Institutes of Health under award number R01AG055480. The content is solely the responsibility of the authors and does not necessarily represent the official views of the National Institutes of Health.
setup_projects()
for getting started.
projects()
, tasks()
, authors()
, and
affiliations()
tablesReturns a table of the projects/tasks/authors/affiliations, filtered and joined according to the entirely optional arguments.
affiliations(affiliation, authors = FALSE) authors(author, affiliations = FALSE, projects = FALSE) tasks(project, lead, archived = FALSE) projects( project, all_stages = FALSE, exclude = c(0L, 6L), path = NULL, archived = FALSE, verbose = FALSE, authors = FALSE ) ideas(project, archived = FALSE, verbose = FALSE, authors = FALSE) manuscripts(project, archived = FALSE, verbose = FALSE, authors = FALSE)
affiliations(affiliation, authors = FALSE) authors(author, affiliations = FALSE, projects = FALSE) tasks(project, lead, archived = FALSE) projects( project, all_stages = FALSE, exclude = c(0L, 6L), path = NULL, archived = FALSE, verbose = FALSE, authors = FALSE ) ideas(project, archived = FALSE, verbose = FALSE, authors = FALSE) manuscripts(project, archived = FALSE, verbose = FALSE, authors = FALSE)
projects , authors , affiliations
|
Logical values indicating whether or not
to perform a left join with another metadata tibble. All |
project , author , affiliation , lead
|
An optional unique vector of
|
archived |
Logical, indicating whether or not to include projects that
have been archived using |
all_stages |
Logical, indicating whether or not to include projects of
all stages, overriding the |
exclude |
A vector of numbers or character strings that can be validated against the list of project stages:
Ignored if |
path |
A single file path of a directory within the main projects folder; only projects whose folder is in this directory will be returned. |
verbose |
Logical, indicating whether or not to return all columns of
the |
ideas()
is a shortcut for projects(exclude = 1:6)
(including
only projects of stage 0: idea
).
manuscripts()
is a shortcut for projects(exclude = c(0:3, 6))
(yielding only projects of stage 4: manuscript
and 5: under
review
).
If one or more of the projects
, authors
, or affiliations
arguments is set to TRUE
, a dplyr::left_join()
is
performed, with the "left" table being the one sharing the name of the
function being used. As such, rows that don't have matches in any other
tables will still show up in the output, and rows that have multiple matches
in other tables will yield multiple rows in the output. The "right" table's
id
column (if present) will be renamed.
A tibble
.
############################################################################# # SETUP old_home <- Sys.getenv("HOME") old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH") temp_dir <- tempfile("dir") dir.create(temp_dir) Sys.unsetenv("PROJECTS_FOLDER_PATH") Sys.setenv(HOME = temp_dir) setup_projects(path = temp_dir) new_affiliation(department_name = "Math Dept.", institution_name = "Springfield College", address = "123 College St, Springfield, AB") new_affiliation(department_name = "Art Department", institution_name = "Springfield College", address = "321 University Boulevard, Springfield, AB", id = 42) new_affiliation(department_name = "Central Intelligence Agency", institution_name = "United States Government", address = "888 Classified Dr, Washington DC") new_affiliation(department_name = "Pyrotechnics", institution_name = "ACME") new_author(given_names = "Spiro", last_name = "Agnew", degree = "LLB", affiliations = "Art D", id = 13) new_author(given_names = "Plato", id = 303) new_author(given_names = "Condoleezza", last_name = "Rice", affiliations = c(1, 42, "Agency", "ACME")) new_project(title = "Test project 1", current_owner = "Plato", stage = 1) new_project(title = "Test project 2", current_owner = "eezza", stage = 2) new_project(title = "Test project 3", current_owner = "Plato", stage = 3) new_project(title = "Fun project 4", current_owner = "Rice", stage = 4) new_project(title = "Fun project 5", current_owner = "Rice", stage = 5) new_project(title = "Fun project 6", current_owner = "Rice", stage = 6) new_project(title = "Good idea", current_owner = "Rice", stage = 0) new_task(2, "take a break", lead = "eezza", done = 1) new_task(2, "go home", TID = 1, lead = 303, timing = 1337) new_task(1, "tie up loose ends", status = "untying a knot", effort = Inf) new_task(3, "cook dinner", lead = "plato") ############################################################################# # View entire affiliations table affiliations() # View authors table joined to affiliations table # Notice that multiple rows are created for each affiliation-author combination authors(affiliations = TRUE) # View only active projects with "Fun" in their title. projects("Fun") # View all projects with "Rice" as the current_owner projects(all_stages = TRUE) %>% dplyr::filter(current_owner == "Rice") # View manuscripts manuscripts() # View ideas ideas() # View tasks tasks() # View only Project 1's tasks tasks(1) # View only Plato's tasks tasks(lead = "plato") # View only Plato's tasks in project 1 tasks(1, "plato") # Wrapped in if (interactive()) because it requires interactive console input # and fails automated testing. if (interactive()) { # Archive Fun project 5 archive_project("Fun project 5") # Default behavior is to not include archived projects in projects() table projects("Fun") projects("Fun", archived = TRUE) } ############################################################################# # CLEANUP # (or, the user can just restart R) Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath)
############################################################################# # SETUP old_home <- Sys.getenv("HOME") old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH") temp_dir <- tempfile("dir") dir.create(temp_dir) Sys.unsetenv("PROJECTS_FOLDER_PATH") Sys.setenv(HOME = temp_dir) setup_projects(path = temp_dir) new_affiliation(department_name = "Math Dept.", institution_name = "Springfield College", address = "123 College St, Springfield, AB") new_affiliation(department_name = "Art Department", institution_name = "Springfield College", address = "321 University Boulevard, Springfield, AB", id = 42) new_affiliation(department_name = "Central Intelligence Agency", institution_name = "United States Government", address = "888 Classified Dr, Washington DC") new_affiliation(department_name = "Pyrotechnics", institution_name = "ACME") new_author(given_names = "Spiro", last_name = "Agnew", degree = "LLB", affiliations = "Art D", id = 13) new_author(given_names = "Plato", id = 303) new_author(given_names = "Condoleezza", last_name = "Rice", affiliations = c(1, 42, "Agency", "ACME")) new_project(title = "Test project 1", current_owner = "Plato", stage = 1) new_project(title = "Test project 2", current_owner = "eezza", stage = 2) new_project(title = "Test project 3", current_owner = "Plato", stage = 3) new_project(title = "Fun project 4", current_owner = "Rice", stage = 4) new_project(title = "Fun project 5", current_owner = "Rice", stage = 5) new_project(title = "Fun project 6", current_owner = "Rice", stage = 6) new_project(title = "Good idea", current_owner = "Rice", stage = 0) new_task(2, "take a break", lead = "eezza", done = 1) new_task(2, "go home", TID = 1, lead = 303, timing = 1337) new_task(1, "tie up loose ends", status = "untying a knot", effort = Inf) new_task(3, "cook dinner", lead = "plato") ############################################################################# # View entire affiliations table affiliations() # View authors table joined to affiliations table # Notice that multiple rows are created for each affiliation-author combination authors(affiliations = TRUE) # View only active projects with "Fun" in their title. projects("Fun") # View all projects with "Rice" as the current_owner projects(all_stages = TRUE) %>% dplyr::filter(current_owner == "Rice") # View manuscripts manuscripts() # View ideas ideas() # View tasks tasks() # View only Project 1's tasks tasks(1) # View only Plato's tasks tasks(lead = "plato") # View only Plato's tasks in project 1 tasks(1, "plato") # Wrapped in if (interactive()) because it requires interactive console input # and fails automated testing. if (interactive()) { # Archive Fun project 5 archive_project("Fun project 5") # Default behavior is to not include archived projects in projects() table projects("Fun") projects("Fun", archived = TRUE) } ############################################################################# # CLEANUP # (or, the user can just restart R) Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath)
Invokes utils::browseURL("mailto://[author emails]")
for
a specified project, or for the currently open project if project
is
left as NULL
.
email_authors( project = NULL, browser = getOption("browser"), encodeIfNeeded = FALSE )
email_authors( project = NULL, browser = getOption("browser"), encodeIfNeeded = FALSE )
project |
Project |
browser , encodeIfNeeded
|
See |
The success of this function depends on the platform and the specified
browser
. See the Details and URL schemes sections of
utils::browseURL()
.
If project = NULL
, the function selects the project in the
projects()
table whose path
is equal to
rstudioapi::getActiveProject()
.
utils::browseURL()
;
rstudioapi::getActiveProject()
for information on
browser
and encodeIfNeeded
arguments.
# Wrapped in if (interactive()) because this function is interactive by nature. if (interactive()) { # If you have a projects() project open, just run it: email_authors() # Otherwise, specify a project: ########################################################################### # Setup old_home <- Sys.getenv("HOME") old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH") temp_dir <- tempfile("dir") dir.create(temp_dir) Sys.unsetenv("PROJECTS_FOLDER_PATH") Sys.setenv(HOME = temp_dir) setup_projects(path = temp_dir) new_author("Rhonda", "Rondale", email = "[email protected]") new_author("Betty", "Betts", email = "[email protected]") new_project("Inventing the Ring of Power", authors = c("Betty", "Ron")) ########################################################################### email_authors("Ring of Power") ########################################################################### # Cleanup (or just restart R) Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath) }
# Wrapped in if (interactive()) because this function is interactive by nature. if (interactive()) { # If you have a projects() project open, just run it: email_authors() # Otherwise, specify a project: ########################################################################### # Setup old_home <- Sys.getenv("HOME") old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH") temp_dir <- tempfile("dir") dir.create(temp_dir) Sys.unsetenv("PROJECTS_FOLDER_PATH") Sys.setenv(HOME = temp_dir) setup_projects(path = temp_dir) new_author("Rhonda", "Rondale", email = "[email protected]") new_author("Betty", "Betts", email = "[email protected]") new_project("Inventing the Ring of Power", authors = c("Betty", "Ron")) ########################################################################### email_authors("Ring of Power") ########################################################################### # Cleanup (or just restart R) Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath) }
Creates a compressed file out of a user-specified project folder for sharing.
export_project(project, zipfile, include_hidden = FALSE, exclude = NULL)
export_project(project, zipfile, include_hidden = FALSE, exclude = NULL)
project |
Project |
zipfile |
Desired file path of the resulting compressed folder file,
including the file's desired name and file extension. See the
|
Logical indicating whether or not to include hidden
folders and files (e.g., those with names that begin with a period).
Defaults to |
|
exclude |
Character vector of exact names of first-level subdirectories of the project folder to exclude from the resulting compressed folder file. |
Currently, this function uses zip::zipr()
.
The name of the created zip file, invisibly.
Tools for Organizing and Managing Project Files
new_project_group(path) rename_folder(project, new_folder_name, archived = FALSE) move_project(project, path, make_directories = FALSE, archived = FALSE) copy_project( project_to_copy, path, new_id = NA, new_folder_name = paste0("p", stringr::str_pad(new_id, 4, pad = "0")), new_short_title = NA, make_directories = FALSE, archived = FALSE ) archive_project(project) open_project(project, new_session = FALSE, archived = FALSE) move_projects_folder( new_path, make_directories = FALSE, .Renviron_path = file.path(Sys.getenv("HOME"), ".Renviron") ) rename_projects_folder( new_name, .Renviron_path = file.path(Sys.getenv("HOME"), ".Renviron") )
new_project_group(path) rename_folder(project, new_folder_name, archived = FALSE) move_project(project, path, make_directories = FALSE, archived = FALSE) copy_project( project_to_copy, path, new_id = NA, new_folder_name = paste0("p", stringr::str_pad(new_id, 4, pad = "0")), new_short_title = NA, make_directories = FALSE, archived = FALSE ) archive_project(project) open_project(project, new_session = FALSE, archived = FALSE) move_projects_folder( new_path, make_directories = FALSE, .Renviron_path = file.path(Sys.getenv("HOME"), ".Renviron") ) rename_projects_folder( new_name, .Renviron_path = file.path(Sys.getenv("HOME"), ".Renviron") )
path |
A valid path string. For See the |
project |
Project |
new_folder_name |
Character string of new name for project folder.
Always processed with |
archived |
Logical indicating whether or not the function should
consider archived projects when determining which project the user is
referring to in the |
make_directories |
Logical. If the path represented by the |
project_to_copy |
Project |
new_id |
Optional integer, ranging from 1 to 9999, used as the
newly-created project |
new_short_title |
Optional character string that becomes the
|
new_session |
Same as the |
new_path |
A valid string indicating a path where the projects folder should be moved. The projects folder will have the same name, but it will be moved into this directory. |
.Renviron_path |
The full file path of the .Renviron file where the user
would like to store the updated |
new_name |
A valid directory name for the projects folder. |
Projects can be moved (move_project()
), copied
(copy_project()
), or archived (archive_project
()).
The difference between delete_project()
and archive_project()
is that the latter will just move the project to a directory called
archive, located in the same parent directory as the project. This
directory gets created if it doesn't yet exist. Most functions that perform
actions on projects will exclude archived projects by default in order to
make it easier for the user to enter a nonambiguous string that will match an
active (i.e., non-archived) project.
Projects can also be organized into groups. By default, all projects are
created within the main projects folder. To create a
project group, which is essentially a subfolder of the main
projects folder, use new_project_group()
.
open_project()
is a wrapper around
rstudioapi::openProject()
, but the user only needs
to know the project's id
, title
, or short_title
instead
of the file path of the project's .Rproj file. If there is no
.Rproj file in the project's folder, the user has the option to
restore a default .Rproj file. If there are multiple .Rproj
files, an error is thrown.
move_projects_folder()
allows the user to move the entire projects
folder created by setup_projects()
into a different directory,
and rename_projects_folder()
changes its name.
new_project()
and delete_project()
for
other functions that write and delete files.
############################################################################# # SETUP old_home <- Sys.getenv("HOME") old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH") temp_dir <- tempfile("dir") dir.create(temp_dir) Sys.unsetenv("PROJECTS_FOLDER_PATH") Sys.setenv(HOME = temp_dir) setup_projects(path = temp_dir) ############################################################################# # setting up a simple project directory tree new_project_group("kidney/clinical") new_project_group("kidney/genomics") new_project_group("prostate/clinical") new_project_group("prostate/genomics") # Wrapped in if (interactive()) because it requires interactive console input # and fails automated package checking and testing. if (interactive()){ new_project(title = "Sample Authorless Project", parent_directory = "kidney") # Moving the project folder, then moving it again. move_project(project = 1, "kidney/genomics") move_project(project = "Sample Authorless Project", "prostate/clinical") # Copying the project copy_project(project_to_copy = 1, "kidney/clinical") # Renaming the folder of the copy of the project rename_folder(project = 2, "copy") # Archiving the copy of the project archive_project(2) # Moving and renaming the entire projects folder temp_dir2 <- tempfile("dir") dir.create(temp_dir2) move_projects_folder(temp_dir2) projects_folder() rename_projects_folder("foobar") projects_folder() # Opens the project in same session open_project("Sample") # Opens the project in a new session open_project(1, new_session = TRUE) } ############################################################################# # CLEANUP Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath)
############################################################################# # SETUP old_home <- Sys.getenv("HOME") old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH") temp_dir <- tempfile("dir") dir.create(temp_dir) Sys.unsetenv("PROJECTS_FOLDER_PATH") Sys.setenv(HOME = temp_dir) setup_projects(path = temp_dir) ############################################################################# # setting up a simple project directory tree new_project_group("kidney/clinical") new_project_group("kidney/genomics") new_project_group("prostate/clinical") new_project_group("prostate/genomics") # Wrapped in if (interactive()) because it requires interactive console input # and fails automated package checking and testing. if (interactive()){ new_project(title = "Sample Authorless Project", parent_directory = "kidney") # Moving the project folder, then moving it again. move_project(project = 1, "kidney/genomics") move_project(project = "Sample Authorless Project", "prostate/clinical") # Copying the project copy_project(project_to_copy = 1, "kidney/clinical") # Renaming the folder of the copy of the project rename_folder(project = 2, "copy") # Archiving the copy of the project archive_project(2) # Moving and renaming the entire projects folder temp_dir2 <- tempfile("dir") dir.create(temp_dir2) move_projects_folder(temp_dir2) projects_folder() rename_projects_folder("foobar") projects_folder() # Opens the project in same session open_project("Sample") # Opens the project in a new session open_project(1, new_session = TRUE) } ############################################################################# # CLEANUP Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath)
Prints a header to the console to be copied and pasted into the YAML of a project protocol or manuscript R Markdown file. These lines essentially produce a title page when the R Markdown file is knitted.
header(project, archived = FALSE)
header(project, archived = FALSE)
project |
Project |
archived |
Logical, indicating whether or not the function should
consider archived projects when determining which project the user is
referring to in the See the Details section of |
The project header consists of:
the project title
the author list
the list of author affiliations
corresponding author information
############################################################################# # SETUP old_home <- Sys.getenv("HOME") old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH") temp_dir <- tempfile("dir") dir.create(temp_dir) Sys.unsetenv("PROJECTS_FOLDER_PATH") Sys.setenv(HOME = temp_dir) setup_projects(path = temp_dir) new_affiliation(department_name = "Math Dept.", institution_name = "Springfield College", address = "123 College St, Springfield, AB") new_affiliation(department_name = "Art Department", institution_name = "Springfield College", address = "321 University Boulevard, Springfield, AB", id = 42) new_affiliation(department_name = "Central Intelligence Agency", institution_name = "United States Government", address = "888 Classified Dr, Washington DC") new_affiliation(department_name = "Pyrotechnics", institution_name = "ACME") new_author(given_names = "Rosetta", last_name = "Stone", affiliations = c(42, "Math"), degree = "PhD", email = "[email protected]", phone = "867-555-5309", id = 8888) new_author(given_names = "Spiro", last_name = "Agnew", degree = "LLB", affiliations = "Art D", id = 13) new_author(given_names = "Plato", id = 303) new_project(title = "Test Project 1", authors = c(13, "303", "Stone"), corresp_auth = "Stone") ############################################################################# header(1) ############################################################################# # CLEANUP Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath)
############################################################################# # SETUP old_home <- Sys.getenv("HOME") old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH") temp_dir <- tempfile("dir") dir.create(temp_dir) Sys.unsetenv("PROJECTS_FOLDER_PATH") Sys.setenv(HOME = temp_dir) setup_projects(path = temp_dir) new_affiliation(department_name = "Math Dept.", institution_name = "Springfield College", address = "123 College St, Springfield, AB") new_affiliation(department_name = "Art Department", institution_name = "Springfield College", address = "321 University Boulevard, Springfield, AB", id = 42) new_affiliation(department_name = "Central Intelligence Agency", institution_name = "United States Government", address = "888 Classified Dr, Washington DC") new_affiliation(department_name = "Pyrotechnics", institution_name = "ACME") new_author(given_names = "Rosetta", last_name = "Stone", affiliations = c(42, "Math"), degree = "PhD", email = "[email protected]", phone = "867-555-5309", id = 8888) new_author(given_names = "Spiro", last_name = "Agnew", degree = "LLB", affiliations = "Art D", id = 13) new_author(given_names = "Plato", id = 303) new_project(title = "Test Project 1", authors = c(13, "303", "Stone"), corresp_auth = "Stone") ############################################################################# header(1) ############################################################################# # CLEANUP Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath)
These functions create, edit, or delete rows in the projects()
,
tasks()
, authors()
, and
affiliations()
tables, which are stored in the .metadata
subdirectory of the main projects folder.
new_project( title = NA, current_owner = NA, stage = c("1: design", "2: data collection", "3: analysis", "4: manuscript", "5: under review", "6: accepted", "0: idea"), impact = NA, status = "just created", short_title = NA, authors = NULL, corresp_auth = NA, creator = NA, deadline_type = NA, deadline = NA, id = NA, folder_name = paste0("p", stringr::str_pad(id, 4, pad = "0")), parent_directory = projects_folder(), make_directories = FALSE, template_folder = "default_folder" ) new_idea(title, status = "just an idea", ...) new_task( project, task = NA, TID = Inf, lead = NA, effort = NA, timing = NA, status = NA, done = 0L, archived = FALSE ) new_author( given_names = NA, last_name = NA, title = NA, affiliations = NULL, degree = NA, email = NA, phone = NA, id = NA ) new_affiliation( department_name = NA, institution_name = NA, address = NA, id = NA ) edit_project( project, title = NULL, short_title = NULL, authors = NULL, current_owner = NULL, status = NULL, deadline_type = NULL, deadline = NULL, stage = NULL, impact = NULL, corresp_auth = NULL, creator = NULL, archived = FALSE ) delete_project(project, archived = FALSE) edit_task( project, TID, new_TID = NULL, lead = NULL, effort = NULL, timing = NULL, status = NULL, done = NULL, archived = FALSE ) finish(project, TID, archived = FALSE) delete_task(project, TID, archived = FALSE) edit_author( author, given_names = NULL, last_name = NULL, affiliations = NULL, title = NULL, degree = NULL, email = NULL, phone = NULL ) delete_author(author) edit_affiliation( affiliation, department_name = NULL, institution_name = NULL, address = NULL ) delete_affiliation(affiliation)
new_project( title = NA, current_owner = NA, stage = c("1: design", "2: data collection", "3: analysis", "4: manuscript", "5: under review", "6: accepted", "0: idea"), impact = NA, status = "just created", short_title = NA, authors = NULL, corresp_auth = NA, creator = NA, deadline_type = NA, deadline = NA, id = NA, folder_name = paste0("p", stringr::str_pad(id, 4, pad = "0")), parent_directory = projects_folder(), make_directories = FALSE, template_folder = "default_folder" ) new_idea(title, status = "just an idea", ...) new_task( project, task = NA, TID = Inf, lead = NA, effort = NA, timing = NA, status = NA, done = 0L, archived = FALSE ) new_author( given_names = NA, last_name = NA, title = NA, affiliations = NULL, degree = NA, email = NA, phone = NA, id = NA ) new_affiliation( department_name = NA, institution_name = NA, address = NA, id = NA ) edit_project( project, title = NULL, short_title = NULL, authors = NULL, current_owner = NULL, status = NULL, deadline_type = NULL, deadline = NULL, stage = NULL, impact = NULL, corresp_auth = NULL, creator = NULL, archived = FALSE ) delete_project(project, archived = FALSE) edit_task( project, TID, new_TID = NULL, lead = NULL, effort = NULL, timing = NULL, status = NULL, done = NULL, archived = FALSE ) finish(project, TID, archived = FALSE) delete_task(project, TID, archived = FALSE) edit_author( author, given_names = NULL, last_name = NULL, affiliations = NULL, title = NULL, degree = NULL, email = NULL, phone = NULL ) delete_author(author) edit_affiliation( affiliation, department_name = NULL, institution_name = NULL, address = NULL ) delete_affiliation(affiliation)
title |
For For the |
current_owner , corresp_auth , creator , lead
|
An If If |
stage |
A number or string that will partially match exactly one of
For See projects_stage-class. |
impact |
A scalar numeric value, intended to communicate the estimated impact the project will have. |
status |
A free text field, intended to communicate the most current condition the project or task is in. For |
short_title |
A nickname for the project. Can be used in other
|
authors , affiliations
|
For For Authors and affiliations may be specified by |
deadline_type |
A free text field, intended to communicate the meaning
of the next field, |
deadline |
A |
id |
An integer that will become the item's permanent identification number. Must be in the range 1-9999 or left blank. If left blank, the lowest available integer in the aforementioned range will be selected. |
folder_name |
A character string that can serve as a valid directory
name. By default, it is "p" followed by the project |
parent_directory |
A character string that can be read as a file path. Can be either:
In any case, the result is that the new project folder will be a
subdirectory of the main projects folder. See also
|
make_directories |
Logical, indicating whether or not
|
template_folder |
A character string naming a folder in the
.templates folder that will be copied into the
projects folder as the new project folder, renamed
according to the value of the |
... |
Additional arguments to be passed to |
project , author , affiliation
|
The |
task |
The name / very short description of the task. |
TID |
The "task ID." For For |
effort , timing
|
Any scalar numeric value, intended to communicate the level of effort the task will require and the nature of the timing of the task, respectively. |
done |
Used to indicate whether or not the task has been completed. Must
be |
archived |
Logical indicating whether or not the function should
consider archived projects when determining which project the user is
referring to in the See the Details section of |
given_names , last_name , department_name , institution_name
|
Each a single character string. Can be used whenever needing to specify a specific author/affiliation. |
degree |
A character string (preferably an abbreviation) denoting the
author's academic degree(s). Will be written next to author names when
|
email , phone
|
A character string denoting the email/phone of the author.
Email will be coerced to lowercase. When a project is given a
|
address |
A character string indicating the address of the affiliation. |
new_TID |
Used to change the task ID of the task specified by
|
new_project()
copies the folder in the .templates folder named
by the template_name
argument into the
projects folder, giving it the name specified by the
folder_name
argument. It then creates a line in the
projects()
table for the newly created project, filling many of
its fields with the contents of corresponding arguments of this function. See
setup_projects()
for more information on the .templates
folder.
delete_project()
deletes project folders and removes their line from
the projects()
table.
The edit_*()
functions and the other new_*()
and
delete_*()
functions only create or edit rows in the .metadata
tables.
new_idea()
is a convenience function for quickly creating projects in
the "0: idea"
stage.
finish()
is a shortcut for edit_task(my_project, my_TID, done =
1)
new_affiliation()
and edit_affiliation()
simply return
the new or edited row of the affiliations()
tibble
.
new_project()
, new_author()
, edit_project()
,
edit_author()
, and the delete_*()
functions
invisibly return the row of the corresponding metadata
tibble
that was added/edited/deleted, although the contents of this
row are printed as a side-effect along with the other relevant information
where applicable (e.g., project authors, author affiliations, project file
paths).
new_idea()
returns the id
, title
, and status
columns of the newly created row of the projects()
tibble
.
############################################################################# # SETUP old_home <- Sys.getenv("HOME") old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH") temp_dir <- tempfile("dir") dir.create(temp_dir) Sys.unsetenv("PROJECTS_FOLDER_PATH") Sys.setenv(HOME = temp_dir) setup_projects(path = temp_dir) ############################################################################# # Creating affiliations new_affiliation(department_name = "Math Dept.", institution_name = "Springfield College", address = "123 College St, Springfield, AB") new_affiliation(department_name = "Art Department", institution_name = "Springfield College", address = "321 University Boulevard, Springfield, AB", id = 42) # Editing an affiliation edit_affiliation("Math Dept", department_name = "Mathematics Department") # Creating authors new_author( given_names = "Rosetta", last_name = "Stone", affiliations = c(42, "Math"), degree = "PhD", email = "[email protected]", phone = "867-555-5309", id = 8888 ) new_author( given_names = "Spiro", last_name = "Agnew", degree = "LLB", affiliations = "Art D", id = 13 ) new_author(last_name = "Plato", id = 303) # Editing an author, showcasing the removal of a text element (last_name) edit_author(author = 303, given_names = "Plato", last_name = NA) # Editing an author, showcasing the addition and removal of affiliations edit_author("Spiro", affiliations = ~ -"Art D" + Math) # Creating a project new_project( title = "Understanding the Construction of the United States", short_title = "USA", authors = c(13, "Stone"), stage = 4, deadline = "2055-02-28", deadline_type = "submission", parent_directory = "famous_studies/philosophers/rocks", corresp_auth = "Stone", current_owner = "agnew", make_directories = TRUE, status = "waiting on IRB" ) # Editing a project, showcasing the addition and removal of authors edit_project( "Understanding", short_title = "usa1", authors = ~ + "303" - 13 - Stone ) # Creating a new idea new_idea(title = "Boiling the Ocean") # Creating some tasks new_task(project = 2, task = "put the horse before the cart", lead = "spiro", timing = NaN) new_task(project = 1, task = "learn something", effort = pi, lead = "Stone", status = "foobar", timing = Inf) new_task(project = 1, task = "take a break", TID = 600.66, effort = -100, status = "throw it all away", lead = "303") new_task(project = 1, task = "tie your shoes", TID = 2, lead = 303) new_task(project = 1, task = "put out the fire", TID = .5, lead = "stone") # Editing a task edit_task(project = "understanding", TID = 3, new_TID = 2, lead = "agnew", done = 1, status = "make dinner") # finish is a shortcut for setting done = 1 on the specified task. finish("construction", 4) # Wrapped in if (interactive()) because it requires interactive console input # and fails automated package checking and testing. if (interactive()) { delete_project("usa1") delete_author(303) delete_task(2, 1) delete_affiliation("Math") } ############################################################################# # CLEANUP Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath)
############################################################################# # SETUP old_home <- Sys.getenv("HOME") old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH") temp_dir <- tempfile("dir") dir.create(temp_dir) Sys.unsetenv("PROJECTS_FOLDER_PATH") Sys.setenv(HOME = temp_dir) setup_projects(path = temp_dir) ############################################################################# # Creating affiliations new_affiliation(department_name = "Math Dept.", institution_name = "Springfield College", address = "123 College St, Springfield, AB") new_affiliation(department_name = "Art Department", institution_name = "Springfield College", address = "321 University Boulevard, Springfield, AB", id = 42) # Editing an affiliation edit_affiliation("Math Dept", department_name = "Mathematics Department") # Creating authors new_author( given_names = "Rosetta", last_name = "Stone", affiliations = c(42, "Math"), degree = "PhD", email = "[email protected]", phone = "867-555-5309", id = 8888 ) new_author( given_names = "Spiro", last_name = "Agnew", degree = "LLB", affiliations = "Art D", id = 13 ) new_author(last_name = "Plato", id = 303) # Editing an author, showcasing the removal of a text element (last_name) edit_author(author = 303, given_names = "Plato", last_name = NA) # Editing an author, showcasing the addition and removal of affiliations edit_author("Spiro", affiliations = ~ -"Art D" + Math) # Creating a project new_project( title = "Understanding the Construction of the United States", short_title = "USA", authors = c(13, "Stone"), stage = 4, deadline = "2055-02-28", deadline_type = "submission", parent_directory = "famous_studies/philosophers/rocks", corresp_auth = "Stone", current_owner = "agnew", make_directories = TRUE, status = "waiting on IRB" ) # Editing a project, showcasing the addition and removal of authors edit_project( "Understanding", short_title = "usa1", authors = ~ + "303" - 13 - Stone ) # Creating a new idea new_idea(title = "Boiling the Ocean") # Creating some tasks new_task(project = 2, task = "put the horse before the cart", lead = "spiro", timing = NaN) new_task(project = 1, task = "learn something", effort = pi, lead = "Stone", status = "foobar", timing = Inf) new_task(project = 1, task = "take a break", TID = 600.66, effort = -100, status = "throw it all away", lead = "303") new_task(project = 1, task = "tie your shoes", TID = 2, lead = 303) new_task(project = 1, task = "put out the fire", TID = .5, lead = "stone") # Editing a task edit_task(project = "understanding", TID = 3, new_TID = 2, lead = "agnew", done = 1, status = "make dinner") # finish is a shortcut for setting done = 1 on the specified task. finish("construction", 4) # Wrapped in if (interactive()) because it requires interactive console input # and fails automated package checking and testing. if (interactive()) { delete_project("usa1") delete_author(303) delete_task(2, 1) delete_affiliation("Math") } ############################################################################# # CLEANUP Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath)
projects_author
vectorObjects of this class contain both the id
and the last_name
of
an author so that the package and the user, respectively, can easily identify
the author.
projects_author(x = character()) is_projects_author(x) match.projects_author(x, table, nomatch = NA_integer_, incomparables = NULL) ## S4 method for signature 'projects_author,ANY' match(x, table, nomatch = NA_integer_, incomparables = NULL) ## S4 method for signature 'ANY,projects_author' match(x, table, nomatch = NA_integer_, incomparables = NULL) ## S4 method for signature 'projects_author,projects_author' match(x, table, nomatch = NA_integer_, incomparables = NULL) `%in%.projects_author`(x, table) ## S4 method for signature 'projects_author' x %in% table
projects_author(x = character()) is_projects_author(x) match.projects_author(x, table, nomatch = NA_integer_, incomparables = NULL) ## S4 method for signature 'projects_author,ANY' match(x, table, nomatch = NA_integer_, incomparables = NULL) ## S4 method for signature 'ANY,projects_author' match(x, table, nomatch = NA_integer_, incomparables = NULL) ## S4 method for signature 'projects_author,projects_author' match(x, table, nomatch = NA_integer_, incomparables = NULL) `%in%.projects_author`(x, table) ## S4 method for signature 'projects_author' x %in% table
x |
For For |
table |
An integer number, a character string, or a
|
nomatch |
See |
incomparables |
An integer number, a character string, or a
|
Essentially, this is a character string of the form:
id: last_name
projects_author()
coerces an integer or character vector to a
projects_author
object, validating each element against the existing
authors()
table.
as.integer()
,
as.double()
, and as.numeric()
return the
id
portion of the projects_author
object as an
integer/double. The methods for the equality and value matching functions
described below make use of these numeric coercion methods. Users desiring
to apply value matching functions other than the ones described below may
similarly take advantage of these.
Methods for ==
,
!=
, match()
, and %in%
enable
users to test equality and to value match among projects_author
objects and as well as between projects_author
objects and unclassed
numbers/characters. When testing or matching against a numeric vector, the
projects_author
object is first coerced to an integer with the
as.integer()
method described above. When testing or matching
against a character vector, the character vector is validated against the
authors()
table.
############################################################################# # SETUP old_home <- Sys.getenv("HOME") old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH") temp_dir <- tempfile("dir") dir.create(temp_dir) Sys.unsetenv("PROJECTS_FOLDER_PATH") Sys.setenv(HOME = temp_dir) setup_projects(path = temp_dir) new_author("chuck", "jonesman", id = 33) new_author("Hattie", "Hatsman", id = 45) ############################################################################# jones <- projects_author("33: Jones") jones as.integer(jones) # 33 jones == 33 # TRUE jones == 10 # FALSE jones != 33 # FALSE jones %in% c(20:40) # TRUE match(jones, c(31:40)) # 3 # Comparing a projects_author object to a character vector results in the # character strings being validated against the authors() table. Then, the id # numbers are compared. jones == c("jOnES", "hat") # TRUE FALSE ############################################################################# # Cleanup (or just restart R) Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath)
############################################################################# # SETUP old_home <- Sys.getenv("HOME") old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH") temp_dir <- tempfile("dir") dir.create(temp_dir) Sys.unsetenv("PROJECTS_FOLDER_PATH") Sys.setenv(HOME = temp_dir) setup_projects(path = temp_dir) new_author("chuck", "jonesman", id = 33) new_author("Hattie", "Hatsman", id = 45) ############################################################################# jones <- projects_author("33: Jones") jones as.integer(jones) # 33 jones == 33 # TRUE jones == 10 # FALSE jones != 33 # FALSE jones %in% c(20:40) # TRUE match(jones, c(31:40)) # 3 # Comparing a projects_author object to a character vector results in the # character strings being validated against the authors() table. Then, the id # numbers are compared. jones == c("jOnES", "hat") # TRUE FALSE ############################################################################# # Cleanup (or just restart R) Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath)
Returns the file path of the main projects folder if it has been established
via setup_projects()
.
projects_folder()
projects_folder()
The file path is returned as a simple character string. It simply returns the
value of Sys.getenv("PROJECTS_FOLDER_PATH")
, provided
that its value is a file path of a directory that actually exists (i.e.,
setup_projects()
has been successfully run).
If it can't find a directory with that path, it returns this string:
projects folder not found. Please run setup_projects()
setup_projects()
for setting up the projects folder.
projects_folder()
projects_folder()
projects_stage
vectorObjects of this class are merely a character string containing a number and a name of one of seven project development stages.
projects_stage(x = character()) match.projects_stage(x, table, nomatch = NA_integer_, incomparables = NULL) ## S4 method for signature 'projects_stage,ANY' match(x, table, nomatch = NA_integer_, incomparables = NULL) ## S4 method for signature 'ANY,projects_stage' match(x, table, nomatch = NA_integer_, incomparables = NULL) ## S4 method for signature 'projects_stage,projects_stage' match(x, table, nomatch = NA_integer_, incomparables = NULL) `%in%.projects_stage`(x, table) ## S4 method for signature 'projects_stage' x %in% table
projects_stage(x = character()) match.projects_stage(x, table, nomatch = NA_integer_, incomparables = NULL) ## S4 method for signature 'projects_stage,ANY' match(x, table, nomatch = NA_integer_, incomparables = NULL) ## S4 method for signature 'ANY,projects_stage' match(x, table, nomatch = NA_integer_, incomparables = NULL) ## S4 method for signature 'projects_stage,projects_stage' match(x, table, nomatch = NA_integer_, incomparables = NULL) `%in%.projects_stage`(x, table) ## S4 method for signature 'projects_stage' x %in% table
x |
For For |
table |
An integer number, a character string, or a
|
nomatch |
See |
incomparables |
An integer number, a character string, or a
|
A projects_stage
object is either a missing value (NA
) or one
of:
0: idea
1: design
2: data collection
3:
analysis
4: manuscript
5: under review
6:
accepted
projects_stage()
validates and coerces a vector of the above integers or strings to a projects_stage
S3 vector.
For projects_stage()
, an S3 vector of class
projects_stage
.
as.integer()
,
as.double()
, and as.numeric()
return the stage
number of the projects_stage
object as an integer/double. The
methods for the comparison and value matching functions described below
make use of these numeric coercion methods. Users desiring to apply value
matching functions other than the ones described below may similarly take
advantage of these.
Methods for the
Comparison operators as well as match()
and
%in%
enable users to test equality and to value match among
projects_stage
objects and as well as between projects_stage
objects and unclassed numbers/characters. When comparing or value matching
against a numeric vector, the projects_stage
object is first coerced
to an integer with the as.integer()
method described above. When
testing or value matching against a character vector, the character vector
is validated against the list of project stages enumerated above.
stage <- projects_stage("4: manuscript") as.integer(stage) # 4 stage == 4 # TRUE stage != 4 # FALSE stage < 6 # TRUE stage %in% c(3:6) # TRUE match(stage, 0:4) # 5 stage %in% c("design", "manusc", "idea") # TRUE more_stages <- projects_stage(c("0: idea", "4: manuscript", "1: design")) match("MAnuscRIPT", more_stages) # 2
stage <- projects_stage("4: manuscript") as.integer(stage) # 4 stage == 4 # TRUE stage != 4 # FALSE stage < 6 # TRUE stage %in% c(3:6) # TRUE match(stage, 0:4) # 5 stage %in% c("design", "manusc", "idea") # TRUE more_stages <- projects_stage(c("0: idea", "4: manuscript", "1: design")) match("MAnuscRIPT", more_stages) # 2
These functions allow the user to reorder a project's authors or an author's affiliations.
reorder_authors(project, ..., after = 0L, archived = FALSE) reorder_affiliations(author, ..., after = 0L)
reorder_authors(project, ..., after = 0L, archived = FALSE) reorder_affiliations(author, ..., after = 0L)
project , author
|
The |
... |
The |
after |
If not specifying explicit ranks in Ignored if ranks are explicitly provided in |
archived |
Logical indicating whether or not the function should
consider archived projects when determining which project the user is
referring to in the See the Details section of |
The order of authors and affiliations affects the order in which these items
appear in the output of header()
.
When specifying explicit ranks, enter ...
as name-value pairs (e.g.,
Johnson = 2, "Baron Cohen" = 4). You can even enumerate authors/affiliations
by their corresponding (quoted) id
numbers (e.g., '7' = 2, ACME = 4,
'22' = 6). If entering an integer greater than the total number of
authors/affiliations, the element will be put at the end. The after
argument will be ignored in this case.
When not specifying explicit ranks, simply enter author/affiliations
id
s or names in the order you want them, and the ones you entered will
be inserted after the position specified by the after
argument. By
default (after = 0
), the authors/affiliations in ...
will be
moved to the front. This behavior corresponds to that of
append()
or forcats::fct_relevel()
.
############################################################################# # SETUP old_home <- Sys.getenv("HOME") old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH") temp_dir <- tempfile("dir") dir.create(temp_dir) Sys.unsetenv("PROJECTS_FOLDER_PATH") Sys.setenv(HOME = temp_dir) setup_projects(path = temp_dir) new_affiliation(department_name = "Math Dept.", institution_name = "Springfield College", address = "123 College St, Springfield, AB") new_affiliation(department_name = "Art Department", institution_name = "Springfield College", address = "321 University Boulevard, Springfield, AB", id = 42) new_affiliation(department_name = "Central Intelligence Agency", institution_name = "United States Government", address = "888 Classified Dr, Washington DC") new_affiliation(department_name = "Pyrotechnics", institution_name = "ACME") new_author(given_names = "Rosetta", last_name = "Stone", affiliations = c(42, "Math"), degree = "PhD", email = "[email protected]", phone = "867-555-5309", id = 8888) new_author(given_names = "Spiro", last_name = "Agnew", degree = "LLB", affiliations = "Art D", id = 13) new_author(given_names = "Plato", id = 303) new_author(given_names = "Condoleezza", last_name = "Rice", degree = "PhD", affiliations = c(1, 42, "Agency", "ACME"), phone = "555-555-5555", email = "[email protected]") new_author(given_names = "Jane", last_name = "Goodall", degree = "PhD", affiliations = 3, id = 5) new_project(title = "Understanding the Construction of the United States", short_title = "USA", authors = c(13, "Stone", "zz", "303", "Jane Goodall"), stage = 4, deadline = "2055-02-28", deadline_type = "submission", parent_directory = "famous_studied/philosophers/rocks", corresp_auth = "Stone", current_owner = "agnew", make_directories = TRUE, status = "waiting on IRB") ############################################################################# # Rice's affiliations before reordering: authors("rice", affiliations = TRUE) # Reordering (with unnamed arguments) reorder_affiliations(author = "RICE", "ACME", 42, after = 1) # Rice's affiliations after reordering: authors("rice", affiliations = TRUE) # Project 1 header before reordering authors: header(1) # Reordering (with named arguments) reorder_authors(project = 1, "Rosetta" = 99, `303` = 2, "5" = 1) # Project 1 header after reordering authors: header(1) ############################################################################# # CLEANUP Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath)
############################################################################# # SETUP old_home <- Sys.getenv("HOME") old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH") temp_dir <- tempfile("dir") dir.create(temp_dir) Sys.unsetenv("PROJECTS_FOLDER_PATH") Sys.setenv(HOME = temp_dir) setup_projects(path = temp_dir) new_affiliation(department_name = "Math Dept.", institution_name = "Springfield College", address = "123 College St, Springfield, AB") new_affiliation(department_name = "Art Department", institution_name = "Springfield College", address = "321 University Boulevard, Springfield, AB", id = 42) new_affiliation(department_name = "Central Intelligence Agency", institution_name = "United States Government", address = "888 Classified Dr, Washington DC") new_affiliation(department_name = "Pyrotechnics", institution_name = "ACME") new_author(given_names = "Rosetta", last_name = "Stone", affiliations = c(42, "Math"), degree = "PhD", email = "[email protected]", phone = "867-555-5309", id = 8888) new_author(given_names = "Spiro", last_name = "Agnew", degree = "LLB", affiliations = "Art D", id = 13) new_author(given_names = "Plato", id = 303) new_author(given_names = "Condoleezza", last_name = "Rice", degree = "PhD", affiliations = c(1, 42, "Agency", "ACME"), phone = "555-555-5555", email = "[email protected]") new_author(given_names = "Jane", last_name = "Goodall", degree = "PhD", affiliations = 3, id = 5) new_project(title = "Understanding the Construction of the United States", short_title = "USA", authors = c(13, "Stone", "zz", "303", "Jane Goodall"), stage = 4, deadline = "2055-02-28", deadline_type = "submission", parent_directory = "famous_studied/philosophers/rocks", corresp_auth = "Stone", current_owner = "agnew", make_directories = TRUE, status = "waiting on IRB") ############################################################################# # Rice's affiliations before reordering: authors("rice", affiliations = TRUE) # Reordering (with unnamed arguments) reorder_affiliations(author = "RICE", "ACME", 42, after = 1) # Rice's affiliations after reordering: authors("rice", affiliations = TRUE) # Project 1 header before reordering authors: header(1) # Reordering (with named arguments) reorder_authors(project = 1, "Rosetta" = 99, `303` = 2, "5" = 1) # Project 1 header after reordering authors: header(1) ############################################################################# # CLEANUP Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath)
Creates a dated text file (.txt) containing the contents of
sessioninfo::session_info()
.
save_session_info(path_dir = here::here("progs", "session_info"))
save_session_info(path_dir = here::here("progs", "session_info"))
path_dir |
The full path of the directory where the session information
text file shall be written. If it doesn't exist, it is written with
|
The date and time when this function was run is included in the resulting
.txt file's name and first line. This date and time is obtained from
Sys.time()
.
For the file name, hyphens (-) are removed from the date, spaces are replaced with underscores (_), and colons (:) are replaced with a modifier letter colon (U+A789).
A list of two:
$ time :
the value of Sys.time()
that the
function used
$ session_info() :
the value of
sessioninfo::session_info()
that the function
used
Creates or restores the projects folder at the user-specified path.
setup_projects( path, folder_name = "projects", overwrite = FALSE, make_directories = FALSE, .Renviron_path = file.path(Sys.getenv("HOME"), ".Renviron") )
setup_projects( path, folder_name = "projects", overwrite = FALSE, make_directories = FALSE, .Renviron_path = file.path(Sys.getenv("HOME"), ".Renviron") )
path |
The file path of the directory inside of which the user
would like the projects folder to be created. Do not include the name of
the projects folder itself (i.e., the value of the argument
|
folder_name |
The name of the projects folder that will be created in
the directory specified by the argument |
overwrite |
Logical indicating whether or not to abandon any previously stored projects folders stored in the system. |
make_directories |
Logical indicating whether or not the function should
write any directories specified in the |
.Renviron_path |
The full file path of the .Renviron file where the user
would like to store the |
The projects
package remembers where the
projects folder is located by storing its file path
in a .Renviron file (the home .Renviron file by default). The entry is
named PROJECTS_FOLDER_PATH
.
Note that changing the .Renviron_path
argument may create an .Renviron
file that R will not notice or use. See Startup for more details.
The project folder's path, invisibly.
The projects folder automatically contains the subdirectories .metadata and .templates, which are hidden by default on some operating systems.
The .metadata folder and its contents should never be manually moved or modified.
The .templates folder is where template project files and folders
should be stored. When this function is successfully run, the default
projects folder template is created (as "default_folder") alongside a few
other template files. When a new project is created,
new_project()
looks here for the folder named by its
template_folder
argument ("default_folder"
by default), and
this folder is copied into the projects folder
(with name specified by the folder_name
argument) as the new project
folder. Users are able and encouraged to customize the
default_folder
to suit their research needs, and may even create
multiple project folder templates for different situations.
The default templates are in the folder located at the path produced by
running: system.file("templates", package = "projects")
If overwrite =
TRUE
, the function will run no matter what. Use with caution.
If the user has a pre-existing projects folder and runs this command with the pre-existing projects folder's path, nothing will be deleted.
Therefore, if the user "broke" the projects folder (e.g., by deleting metadata; by changing the "PROJECTS_FOLDER_PATH" line in the .Renviron file), the user can "fix" the projects folder to some degree by running this function with the folder's actual file path (e.g., restore all default templates; restore missing metadata files).
new_project()
for information on templates
Startup for more information on how .Renviron files work.
############################################################################# # Setup # Any existing "projects" folder is left totally untouched, # and the user's home directory and .Renviron file are also left untouched. old_home <- Sys.getenv("HOME") old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH") temp_dir <- tempfile("dir") dir.create(temp_dir) Sys.setenv(HOME = temp_dir) Sys.unsetenv("PROJECTS_FOLDER_PATH") ############################################################################# # Creating the projects folder setup_projects(path = temp_dir) # Viewing the projects folder path: path1 <- projects_folder() # Viewing the contents of the projects folder: list.files(path1, full.names = TRUE, recursive = TRUE, all.files = TRUE) # Create an arbitrary subfolder in temp_dir: subfolder_path <- file.path(temp_dir, "test") dir.create(subfolder_path) # Wrapped in if (interactive()) because it requires user input if (interactive()) { # The function won't let the user abandon the old projects folder... setup_projects(path = subfolder_path) # ...unless overwrite = TRUE setup_projects(path = file.path(temp_dir, "test"), overwrite = TRUE) # Even then, only the stored location of the projects folder is overwritten. # The old projects folder still exists: list.files(path1, full.names = TRUE, recursive = TRUE, all.files = TRUE) # Giving the "projects" folder a different name: setup_projects(path = temp_dir, folder_name = "studies", overwrite = TRUE) } ############################################################################# # Cleanup # (or, the user can just restart R) Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath) #############################################################################
############################################################################# # Setup # Any existing "projects" folder is left totally untouched, # and the user's home directory and .Renviron file are also left untouched. old_home <- Sys.getenv("HOME") old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH") temp_dir <- tempfile("dir") dir.create(temp_dir) Sys.setenv(HOME = temp_dir) Sys.unsetenv("PROJECTS_FOLDER_PATH") ############################################################################# # Creating the projects folder setup_projects(path = temp_dir) # Viewing the projects folder path: path1 <- projects_folder() # Viewing the contents of the projects folder: list.files(path1, full.names = TRUE, recursive = TRUE, all.files = TRUE) # Create an arbitrary subfolder in temp_dir: subfolder_path <- file.path(temp_dir, "test") dir.create(subfolder_path) # Wrapped in if (interactive()) because it requires user input if (interactive()) { # The function won't let the user abandon the old projects folder... setup_projects(path = subfolder_path) # ...unless overwrite = TRUE setup_projects(path = file.path(temp_dir, "test"), overwrite = TRUE) # Even then, only the stored location of the projects folder is overwritten. # The old projects folder still exists: list.files(path1, full.names = TRUE, recursive = TRUE, all.files = TRUE) # Giving the "projects" folder a different name: setup_projects(path = temp_dir, folder_name = "studies", overwrite = TRUE) } ############################################################################# # Cleanup # (or, the user can just restart R) Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath) #############################################################################
Safely updates existing project metadata to be compatible with
projects
1.X.X.
update_metadata(ask = TRUE)
update_metadata(ask = TRUE)
ask |
Logical, indicating whether or not the user would be asked at the
command line whether or not to proceed. Defaults to |
Prior to projects
1.X.X, the stage
,
current_owner
, corresp_auth
, and creator
columns of the
projects()
table were different.
The stage
column was a factor, and users had to type stage
names exactly, down to the integer, colon, and space. Now, this column is of
class projects_stage-class
.
The latter three columns were integers corresponding to id
s in the
authors()
table, so users would have to query that table if
they did not remember which author was denoted by the integer id
.
projects_stage-class
;
projects_author-class
.