Use Package Skeleton
Examples
## valid pkg folder
pkg_name <- "pkgname"
pkg_dir <- file.path(tempdir(), pkg_name)
pkg_dir <- create_pkg_dir(pkg_dir)
#> C:\Users\RUNNER~1\AppData\Local\Temp\RtmpmSkFFM/pkgname is a valid 'root_dir' for pkg 'pkgname'
#> Warning: C:\Users\RUNNER~1\AppData\Local\Temp\RtmpmSkFFM/pkgname was not created as it already existed.
withr::with_dir(pkg_dir, {use_pkg_skeleton(pkg_name)})
#> ✔ Setting active project to
#> "C:/Users/runneradmin/AppData/Local/Temp/RtmpmSkFFM/pkgname".
#> ✔ Writing pkgname.Rproj.
#> ✔ Adding ".Rproj.user" to .gitignore.
#> NULL