Description Usage Arguments Details Value Author(s) Examples
View source: R/package_functions.R
Link an R (or Rmd) script to the project environment so that it will be integrated with the "main.R" script created at the set up of the project.
1 | link_to_proj(init = F, install = T)
|
init |
Boolean (T, F) indicator of whether to initialize git |
install |
Boolean (T, F) indicator of whether to install packages |
This is the most important function in the package. It first looks for the project root by looking for the folder path to "main.R". If it does not find this file, it will prompt the user to specify a path. Once the user specifies the path, the "main.R" file will be automatically created in that folder along with "example.R". It then stores this folder as "root.dir" in the package environment. It also creates a ".gitignore" file and initializes the root directory for git in case the user would like to use git features.
Once the root directory is set, it will build the folder structure if it does not exist. This structure consists of folders "Codes", "Functions", "Input", "Output", "Documentation", and "Logs". You should store all your R scripts in "Codes" except R scripts containing functions to be used by other R scripts. Those should be stored in "Functions". All input data used R scripts should be store in "Input". All output data and images should be stored in "Output". All documenation files created by Rmd scripts should be stored in "Documentation". "Logs" will contain output information created after sourcing "main.R".
Next, the file cabinet is built and saved in the "Functions" folder. If the cabinet already exists, it will load it into the project environment.
Finally, the function searches all R scripts for "library" and "require" keywords. It will check that all packages in these keywords are installed, and if they are not, install them. If any package versions differ from previous runs, it will prompt to update for the correct package version. it will open a web browser and ask the user to verify access. Authenication tokens will be stored in the project folder to prevent this from happening on future runs. The authentication token may be updated periodically.
If the project root is already stored in the package environment, the above will not be run and will only set the "current.file" in the package environment that stores the path of the current R script.
No return value
Alex Hubbard (hubbard.alex@gmail.com)
1 | link_to_proj(init = F)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.