Project Template Creates Folders 1 level up

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)

}

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"))
}

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:

1 Like

Thanks. First-timer here :wink:

1 Like