-
Notifications
You must be signed in to change notification settings - Fork 0
/
00-gdrive_project.R
98 lines (67 loc) · 3.43 KB
/
00-gdrive_project.R
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
####################################################
########### Google Drive Project Template ##########
####################################################
####################################
########## load libraries ##########
####################################
## Install the required script packages if not yet installed
# Install pacman package if necessary
if(!"pacman" %in% rownames(installed.packages())) install.packages("pacman")
pacman::p_load(googledrive, rio, tidyverse)
#####################################
########## Google Drive #############
#####################################
## vignette for 'googledrive' here: https://googledrive.tidyverse.org/
## login to Google Drive
# if using RStudio Server set use_oob = TRUE, if using Rstudio locally you can set use_oob = FALSE
drive_auth(use_oob = TRUE)
##########################################################################
########## locate files or folders in Google Drive #######################
##########################################################################
# show root folder directories
drive_ls("~/")
# if using Google Team Drives then use this commmand:
team_drive_find()
##################################################################
############## create template in Google Drive ###################
##################################################################
## create the GPL"s Project Template on your Google Drive within RStudio
# make new project folder using Google Drive file 'id'
project <- drive_mkdir("PROJECT_NAME_HERE", # project name here
parent = as_id('GDRIVE_FILE_ID_HERE')) # insert your project 'id' here
project_lit <- drive_mkdir("Literature",
parent = as_id(project$id))
project_mat <- drive_mkdir("Materials and Methods",
parent = as_id(project$id))
project_doc <- drive_mkdir("Notes and Documentation",
parent = as_id(project$id))
project_ana <- drive_mkdir("Analysis Scripts",
parent = as_id(project$id))
project_dat <- drive_mkdir("Data",
parent = as_id(project$id))
project_raw <- drive_mkdir("Raw Data",
parent = as_id(project_dat$id))
project_out <- drive_mkdir("Scholarly Output",
parent = as_id(project$id))
project_reg <- drive_mkdir("Registration",
parent = as_id(project$id))
# copy registration form into your project folder
registration_form <- drive_cp(as_id('14qNm5tLQhOrDs_Q-eh3e25hv4nXZVHBdbpsdVc9_Ywg'),
path = project_reg,
name = "Pre-Registration of Project")
## create list of the OSF project IDs for later reference
project_info <- list()
project_info$project <- project
project_info$project_lit <- project_lit
project_info$project_mat <- project_mat
project_info$project_doc <- project_doc
project_info$project_ana <- project_ana
project_info$project_dat <- project_dat
project_info$project_raw <- project_raw
project_info$project_out <- project_out
project_info$project_reg <- project_reg
# verify IDs were correctly saved
project_info
# save Google Drive 'ids' to you can use them later if necessary
if(!exists("./project_info")) {dir.create("./project_info")} # this is where we will save our tables
rio::export(as.data.frame(project_info), "./project_info/gdrive_project_info.csv")