-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpilotReturn.R
More file actions
35 lines (27 loc) · 1.27 KB
/
pilotReturn.R
File metadata and controls
35 lines (27 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
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
# EVENT: Pilot returns article
# 1. Download the Articles sheet.
# 2. Update reproducibilityStatus column for this id to 'inPool'.
# 3. Update pilot column to '?'
pilotReturn <- function(articleID){
# load packages and custom function
library(googlesheets)
library(tidyverse)
pull <- function(x,y) {x[,if(is.name(substitute(y))) deparse(substitute(y)) else y, drop = FALSE][[1]]}
# 1. Download the Articles sheet and extract the data
articlesSheet <- gs_title("Articles")
articlesData <- articlesSheet %>% gs_read()
# throw an error if article id is not present
allID <- articlesData %>% pull(id)
if(!(articleID %in% allID)) stop('Cannot find this article ID in spreadsheet!')
# 2. Update reproducibilityStatus column for this id to 'inPool'.
# 3. and update 'pilot' column to '?'
# first make changes
articles_mod <- articlesData %>%
mutate(reproducibilityStatus = ifelse(id == articleID, 'inPool', reproducibilityStatus),
pilot = ifelse(id == articleID, '?', pilot))
# now write new csv file
write.csv(articles_mod, 'articles_mod.csv', row.names = F)
# now upload csv and overwrite old sheet
gs_upload("articles_mod.csv", sheet_title = 'Articles', overwrite = TRUE)
print("Article returned to Reproducibility Pool.")
}