phdjsep
September 20, 2018, 7:39pm
1
Hello,
I'm following these directions for creating a Project Template in RStudio Server and everything seems to be working except the directories and files are being created one folder up from the project. I can't see the reason why. Any help would be sincerely appreciated!
starter <- function(path, ...) {
# ensure path exists
dir.create(path, recursive = TRUE, showWarnings = FALSE)
# Create directories
dir.create(“data”)
dir.create(“data/raw”)
dir.create(“data/interim”)
dir.create(“data/processed”)
dir.create(“data/external”)
dir.create(“docs”)
dir.create(“models”)
dir.create(“reports”)
dir.create(“graphs”)
dir.create(“utilities”)
dir.create(“src”)
dir.create(“src/data”)
dir.create(“src/analysis”)
# Create files
file.create(“README.md”)
fileConn <- file(“README.md”)
writeLines(c(“#Project Title”,“##Description”, “##Confluence Link”), fileConn)
close(fileConn)
}
phdjsep
September 20, 2018, 10:31pm
2
Solved!
starter <- function(path, ...) {
# ensure path exists
dir.create(path, recursive = TRUE, showWarnings = FALSE)
# Create directories
dir.create(file.path(path, "data"))
dir.create(file.path(path, "data/raw"))
dir.create(file.path(path, "data/interim"))
dir.create(file.path(path, "data/processed"))
dir.create(file.path(path, "data/external"))
dir.create(file.path(path, "docs"))
dir.create(file.path(path, "models"))
dir.create(file.path(path, "reports"))
dir.create(file.path(path, "graphs"))
dir.create(file.path(path, "utilities"))
dir.create(file.path(path, "src"))
dir.create(file.path(path, "src/data"))
dir.create(file.path(path, "src/analysis"))
# Create files
file.create(file.path(path, "README.md"))
}
jcblum
September 21, 2018, 3:41am
3
If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:
If your question has been answered don't forget to mark the solution
Folks in the future can come along and easily see what worked for you.
You acknowledge the person who solved the issue.
If you're the original poster and the category allows solutions to be marked there should be a little box at the bottom of replies that you can click to select that response as your "solution."
Before:
[image]
After:
[image]
Based on replies by @mara
1 Like