Skip to content

Commit

Permalink
Code updates to remove warnings; updated templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Krieger committed Apr 24, 2021
1 parent ed1cf25 commit 6000468
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 48 deletions.
5 changes: 2 additions & 3 deletions DESCRIPTION
@@ -1,6 +1,6 @@
Package: projects
Title: A Project Infrastructure for Researchers
Version: 2.1.2
Version: 2.1.3
Authors@R:
c(person(given = "Nik",
family = "Krieger",
Expand Down Expand Up @@ -40,8 +40,7 @@ Suggests:
here (>= 0.1),
testthat (>= 2.3.2)
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.0
RoxygenNote: 7.1.1
Collate:
'set_generics.R'
'class-projects_author.R'
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
@@ -1,4 +1,11 @@

# projects 2.1.3

## Minor updates:
- Removed names from arguments passed to `readr::write_lines()` and `readr::write_rds()` since they have deprecated `path` in favor of `file`.
- Combined the `setup` and `load_libraries` code chunks in all applicable template .Rmd files.
- Removed `LazyData` line from `DESCRIPTION` file in compliance with new CRAN check.

# projects 2.1.2

## Minor updates:
Expand Down
6 changes: 3 additions & 3 deletions R/file_management.R
Expand Up @@ -465,7 +465,7 @@ archive_project <- function(project) {

projects_table$path[projects_table$id == project_row$id] <- new_path

readr::write_rds(x = projects_table, path = projects_path)
readr::write_rds(projects_table, projects_path)

print(dplyr::filter(projects_table, .data$id == project_row$id))
message("\nThe above project was archived and has the file path\n", new_path)
Expand Down Expand Up @@ -640,7 +640,7 @@ move_projects_folder <- function(new_path,
replacement = new_path
)

readr::write_rds(projects_table, path = projects_path)
readr::write_rds(projects_table, projects_path)

message("\nProjects folder moved so that its new path is\n", new_path2)
}
Expand Down Expand Up @@ -699,7 +699,7 @@ rename_projects_folder <- function(new_name,
replacement = new_path
)

readr::write_rds(projects_table, path = projects_path)
readr::write_rds(projects_table, projects_path)

message("\nProjects folder renamed so that its new path is:\n", new_path)
}
12 changes: 6 additions & 6 deletions R/metadata_manipulation.R
Expand Up @@ -52,7 +52,7 @@ add_metadata <- function(table, new_row, table_path) {

table <- vec_rbind(table, new_row)

readr::write_rds(x = table, path = table_path)
readr::write_rds(table, table_path)

table[nrow(table), ]
}
Expand All @@ -73,7 +73,7 @@ edit_metadata <- function(table, row_id, ..., table_path) {
}
)

readr::write_rds(x = table, path = table_path)
readr::write_rds(table, table_path)

table[row_number, ]
}
Expand All @@ -84,7 +84,7 @@ delete_metadata <- function(table, row_id, table_path) {

table <- table[table$id != row_id, ]

readr::write_rds(x = table, path = table_path)
readr::write_rds(table, table_path)
}


Expand All @@ -93,7 +93,7 @@ add_assoc <- function(assoc_table, new_rows, assoc_path) {

assoc_table <- rbind(assoc_table, new_rows)

readr::write_rds(x = assoc_table, path = assoc_path)
readr::write_rds(assoc_table, assoc_path)

assoc_table
}
Expand All @@ -109,7 +109,7 @@ delete_assoc <- function(assoc_table, ..., assoc_path) {
dplyr::anti_join(assoc_table, assoc_to_delete)
)

readr::write_rds(x = assoc_table, path = assoc_path)
readr::write_rds(assoc_table, assoc_path)

assoc_table
}
Expand All @@ -125,7 +125,7 @@ change_special_author <- function(author_id,
change_matrix <- projects_table[special_author_cols] == author_id
if (isTRUE(any(change_matrix))) {
projects_table[special_author_cols][change_matrix] <- new_value
readr::write_rds(x = projects_table, path = projects_path)
readr::write_rds(projects_table, projects_path)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions R/setup.R
Expand Up @@ -227,7 +227,7 @@ set_Renviron <- function(projects_folder_path, .Renviron_path) {
)
)

readr::write_lines(Renviron_entries, path = .Renviron_path)
readr::write_lines(Renviron_entries, .Renviron_path)
Sys.setenv(PROJECTS_FOLDER_PATH = projects_folder_path)
}

Expand Down Expand Up @@ -360,7 +360,7 @@ restore_metadata <- function(path) {
if (fs::file_exists(rds_path)) {
tibble <- vec_rbind(readRDS(rds_path), tibble)
}
readr::write_rds(x = tibble, path = rds_path)
readr::write_rds(tibble, rds_path)
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/update.R
Expand Up @@ -102,7 +102,7 @@ update_metadata <- function(ask = TRUE) {
projects_table$creator <- creator_results$results
}

readr::write_rds(x = projects_table, path = projects_path)
readr::write_rds(projects_table, projects_path)

message("\nProjects metadata updated.")

Expand Down
50 changes: 25 additions & 25 deletions README.md
Expand Up @@ -378,7 +378,7 @@ library(projects)
``` r
setup_projects("~")
#> projects folder created at
#> /tmp/RtmpBBoEOw/projects
#> /tmp/RtmpH0SVxn/projects
#>
#> Add affiliations with new_affiliation(),
#> then add authors with new_author(),
Expand Down Expand Up @@ -579,7 +579,7 @@ new_project(
)
#>
#> Project 1 has been created at
#> /tmp/RtmpBBoEOw/projects/p0001
#> /tmp/RtmpH0SVxn/projects/p0001
#> # A tibble: 1 x 6
#> id title stage status deadline_type deadline
#> <int> <chr> <prjstg> <chr> <chr> <dttm>
Expand Down Expand Up @@ -620,7 +620,7 @@ new_project(
)
#>
#> Project 2 has been created at
#> /tmp/RtmpBBoEOw/projects/p0002
#> /tmp/RtmpH0SVxn/projects/p0002
#> # A tibble: 1 x 6
#> id title stage status deadline_type deadline
#> <int> <chr> <prjstg> <chr> <chr> <dttm>
Expand Down Expand Up @@ -653,7 +653,7 @@ new_project(
)
#>
#> Project 1945 has been created at
#> /tmp/RtmpBBoEOw/projects/top_secret/p1945
#> /tmp/RtmpH0SVxn/projects/top_secret/p1945
#> # A tibble: 1 x 6
#> id title stage status deadline_type deadline
#> <int> <chr> <prjstg> <chr> <chr> <dttm>
Expand Down Expand Up @@ -682,7 +682,7 @@ new_project(
)
#>
#> Project 3 has been created at
#> /tmp/RtmpBBoEOw/projects/p0003
#> /tmp/RtmpH0SVxn/projects/p0003
#> # A tibble: 1 x 6
#> id title stage status deadline_type deadline
#> <int> <chr> <prjstg> <chr> <chr> <dttm>
Expand Down Expand Up @@ -801,9 +801,9 @@ projects(verbose = TRUE) %>% select(id, short_title, path)
#> # A tibble: 3 x 3
#> id short_title path
#> <int> <chr> <chr>
#> 1 1945 Dr. Strangelove /tmp/RtmpBBoEOw/projects/top_secret/p1945
#> 2 2 Eureka! /tmp/RtmpBBoEOw/projects/p0002
#> 3 3 Rn86 /tmp/RtmpBBoEOw/projects/p0003
#> 1 1945 Dr. Strangelove /tmp/RtmpH0SVxn/projects/top_secret/p1945
#> 2 2 Eureka! /tmp/RtmpH0SVxn/projects/p0002
#> 3 3 Rn86 /tmp/RtmpH0SVxn/projects/p0003
```

Users can also create subdirectories with the function
Expand All @@ -813,7 +813,7 @@ Users can also create subdirectories with the function
new_project_group("Greek_studies/ancient_studies")
#>
#> The following directory was created:
#> /tmp/RtmpBBoEOw/projects/Greek_studies/ancient_studies
#> /tmp/RtmpH0SVxn/projects/Greek_studies/ancient_studies
```

If a project has already been created, it can be moved **not** with
Expand All @@ -833,7 +833,7 @@ move_project("Crown", path = "Greek_studies/ancient_studies")
#> # creator <prjaut>
#>
#> Project 2 moved so that its new path is
#> /tmp/RtmpBBoEOw/projects/Greek_studies/ancient_studies/p0002
#> /tmp/RtmpH0SVxn/projects/Greek_studies/ancient_studies/p0002

copy_project(
project_to_copy = "Radon",
Expand All @@ -848,7 +848,7 @@ copy_project(
#> # creator <prjaut>
#>
#> Project 4 below is a copy of project 3 and is located at
#> /tmp/RtmpBBoEOw/projects/dangerous_studies/radioactive_studies/radon_studies/p0004
#> /tmp/RtmpH0SVxn/projects/dangerous_studies/radioactive_studies/radon_studies/p0004
#> # A tibble: 1 x 11
#> id title short_title current_owner status deadline_type deadline
#> <int> <chr> <lgl> <prjaut> <chr> <chr> <dttm>
Expand All @@ -857,9 +857,9 @@ copy_project(
#> # creator <prjaut>
#>
#> The .Rproj file
#> /tmp/RtmpBBoEOw/projects/dangerous_studies/radioactive_studies/radon_studies/p0004/p0003.Rproj
#> /tmp/RtmpH0SVxn/projects/dangerous_studies/radioactive_studies/radon_studies/p0004/p0003.Rproj
#> was renamed to
#> /tmp/RtmpBBoEOw/projects/dangerous_studies/radioactive_studies/radon_studies/p0004/p0004.Rproj
#> /tmp/RtmpH0SVxn/projects/dangerous_studies/radioactive_studies/radon_studies/p0004/p0004.Rproj
#>
#> Be sure to change all instances of "p0003" to "p0004" as desired
#> (e.g., .bib files and references to them in YAML headers).
Expand All @@ -870,9 +870,9 @@ projects(c("Crown", "Radon"), verbose = TRUE) %>% select(id, title, path)
#> # A tibble: 3 x 3
#> id title path
#> <int> <chr> <chr>
#> 1 2 Weighing the C… /tmp/RtmpBBoEOw/projects/Greek_studies/ancient_studies/…
#> 2 4 Understanding … /tmp/RtmpBBoEOw/projects/dangerous_studies/radioactive_…
#> 3 3 Understanding … /tmp/RtmpBBoEOw/projects/p0003
#> 1 2 Weighing the C… /tmp/RtmpH0SVxn/projects/Greek_studies/ancient_studies/…
#> 2 4 Understanding … /tmp/RtmpH0SVxn/projects/dangerous_studies/radioactive_…
#> 3 3 Understanding … /tmp/RtmpH0SVxn/projects/p0003
```

Projects can also be archived; they are moved into a subdirectory called
Expand All @@ -890,7 +890,7 @@ archive_project("Strangelove")
#> # creator <prjaut>
#>
#> The above project was archived and has the file path
#> /tmp/RtmpBBoEOw/projects/top_secret/archive/p1945
#> /tmp/RtmpH0SVxn/projects/top_secret/archive/p1945
```

When a project is archived, it is no longer included in `projects()`
Expand All @@ -901,18 +901,18 @@ projects(verbose = TRUE) %>% select(id, short_title, path)
#> # A tibble: 3 x 3
#> id short_title path
#> <int> <chr> <chr>
#> 1 2 Eureka! /tmp/RtmpBBoEOw/projects/Greek_studies/ancient_studies/p0002
#> 2 4 <NA> /tmp/RtmpBBoEOw/projects/dangerous_studies/radioactive_stud…
#> 3 3 Rn86 /tmp/RtmpBBoEOw/projects/p0003
#> 1 2 Eureka! /tmp/RtmpH0SVxn/projects/Greek_studies/ancient_studies/p0002
#> 2 4 <NA> /tmp/RtmpH0SVxn/projects/dangerous_studies/radioactive_stud…
#> 3 3 Rn86 /tmp/RtmpH0SVxn/projects/p0003

projects(verbose = TRUE, archived = TRUE) %>% select(id, short_title, path)
#> # A tibble: 4 x 3
#> id short_title path
#> <int> <chr> <chr>
#> 1 1945 Dr. Strangelo… /tmp/RtmpBBoEOw/projects/top_secret/archive/p1945
#> 2 2 Eureka! /tmp/RtmpBBoEOw/projects/Greek_studies/ancient_studies/p…
#> 3 4 <NA> /tmp/RtmpBBoEOw/projects/dangerous_studies/radioactive_s…
#> 4 3 Rn86 /tmp/RtmpBBoEOw/projects/p0003
#> 1 1945 Dr. Strangelo… /tmp/RtmpH0SVxn/projects/top_secret/archive/p1945
#> 2 2 Eureka! /tmp/RtmpH0SVxn/projects/Greek_studies/ancient_studies/p…
#> 3 4 <NA> /tmp/RtmpH0SVxn/projects/dangerous_studies/radioactive_s…
#> 4 3 Rn86 /tmp/RtmpH0SVxn/projects/p0003
```

Lastly, affiliations, authors and projects can be deleted with the
Expand Down Expand Up @@ -974,7 +974,7 @@ various stages of development.

# References

<div id="refs" class="references hanging-indent">
<div id="refs" class="references">

<div id="ref-baker20161">

Expand Down
5 changes: 5 additions & 0 deletions cran-comments.md
@@ -1,4 +1,9 @@

## Update to version 2.1.3
There were no ERRORs, WARNINGs.

NOTE on some platforms objecting to `methods` being in the `Imports` list.

## Update to version 2.1.2
There were no ERRORs, WARNINGs.

Expand Down
2 changes: 0 additions & 2 deletions inst/templates/04_report.Rmd
Expand Up @@ -13,9 +13,7 @@ Funding:

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r load_libraries, include=FALSE}
library(projects)
library(here)
library(tidyverse)
Expand Down
3 changes: 0 additions & 3 deletions inst/templates/CONSORT_protocol.Rmd
Expand Up @@ -15,10 +15,7 @@ Funding:

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r load_libraries, include=FALSE}
library(projects)
library(here)
library(tidyverse)
Expand Down
3 changes: 0 additions & 3 deletions inst/templates/STROBE_protocol.Rmd
Expand Up @@ -15,10 +15,7 @@ Funding:

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r load_libraries, include=FALSE}
library(projects)
library(here)
library(tidyverse)
Expand Down

0 comments on commit 6000468

Please sign in to comment.