# NOT RUN {
# SETUP
old_path <- Sys.getenv("PROJECTS_FOLDER_PATH")
setup_projects(path = tempdir(), .Renviron_path = fs::path_temp(".Renviron"))
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)
#############################################################################
# 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()
# 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
Sys.setenv(PROJECTS_FOLDER_PATH = old_path)
fs::file_delete(c(fs::path_temp("projects"), fs::path_temp(".Renviron")))
# }
Run the code above in your browser using DataLab