What is the code go visualize your folder structure in RStudio?
Asked
Active
Viewed 826 times
1 Answers
2
Setting the paths
variable to be the vector of all the files within the directory and all the files within the subfolders of the directory:
paths = unique(c(list.dirs(full.names = T),list.files(full.names = T)))
Then, borrowing the answer from here, we can visualise the structure as a tree:
library(data.tree); library(plyr)
x <- lapply(strsplit(paths, "/"), function(z) as.data.frame(t(z)))
x <- rbind.fill(x)
x$pathString <- apply(x, 1, function(x) paste(trimws(na.omit(x)), collapse="/"))
(mytree <- data.tree::as.Node(x))

VitaminB16
- 1,174
- 1
- 3
- 17