-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadingBae.R
More file actions
30 lines (27 loc) · 960 Bytes
/
Copy pathloadingBae.R
File metadata and controls
30 lines (27 loc) · 960 Bytes
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
#loadingBae
#Method for automated loading of script inputs
#RDS-support only for now
#Goal: Set input directory path, vector of keywords that represent
#you project's input files, output a list of paths to each keyword.
#List slots are named for their keyword.
path = "test/"
key <- c("rownames", "colnames", "data")
loadingBae <- function(path, key){
pathIn <- list()
for(i in seq_along(key)){
pathIn[[key[i]]] = list.files(path = path,
pattern = key[i],
full.names = TRUE,
ignore.case = TRUE)
}
#Check
if(!all(sapply(pathIn, function(x) length(x) > 0))){
cat("Error: One or more input(s) could not be found.\n")
print(sapply(pathIn, function(x) length(x) > 0))
stop()
}else{
cat("\nFound the following inputs: \n")
print(sapply(pathIn, function(x) length(x) > 0))
}
return(pathIn)
}