-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_Notebook.R
38 lines (26 loc) · 1.25 KB
/
run_Notebook.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
library(knitr)
library(data.table)
library(tidyverse)
library(filesstrings)
###### SET UP ######
# Setting up the working directory
syncfolder <- '/Users/isabelfe/GitHub/R.Workshop/'
###### PROCESSING ######
# Listing all the '_input.csv' files in the data_input folder and looping through the file list to run the fixing script
filelist <- list.files(file.path(syncfolder,"data_input"), pattern = '_input.csv', full.names=FALSE)
for (file in filelist) {
file_id <- gsub("_input.csv", "", file) #grep file_id name from the file name
print(paste("Processing file",file_id))
# Saving full paths for all needed input files
fileDataPath <- paste(syncfolder,"data_input/", file, sep="")
# Saving input files as objects
table <- fread(fileDataPath)
# Rendering '05_BasicNotebook.Rmd':
rmarkdown::render(input = "06_BasicNotebook_run.Rmd",
output_format = "html_document",
output_file = paste0(file_id, "_Report.html"),
output_dir = file.path(syncfolder,"data_output", file_id),
params = list(folder = syncfolder))
# Moving input files into 'data_archive'
#file.move(fileDataPath, file.path(paste(syncfolder,"/data_output/", file_id, sep="")), overwrite = TRUE)
}