Go to https://cloud.r-project.org/ and download latest version of R
During the installation process, accept all of the defaults
Once the install is complete, open R - admittedly it’s not very exciting to look at, RStudio will help with that
At the command prompt type .libPaths()
This function returns the directories where R can store your downloaded packages
As you’re installing R for the first time, there may be only one directory listed now - as you use R the number of directories is likely to increase
The order of the directories indicates the order R will use in trying to store the package
A custom library may be specified by creating an environment variable called R_LIBS and assigning it the path of the desired folder
If you don’t know how to set environment variables don’t worry about this right now
Now type names(installed.packages()[,1])
The real power of R is experienced by using AND creating packages
R packages can be downloaded and used like apps on your smartphone
Packages allow researchers to share their work with the world, very quickly
Packages allow users to use the latest methods, almost immediately after they are developed
In many cases an app a package for that!
There are also several ‘stores’ or repositories from which packages can be installed
The Comprehensive R Archive Network (CRAN) - the official repository for R packages
GitHub - many packages are stored here prior to being accepted for publication to the CRAN
Bioconductor - a repository of bioinformatics-related R packages
The Microsoft R Archive Network (MRAN)
Ok, let’s install a package to make sure everything is working
Run install.packages('data.table') to install the data.table package from the CRAN
As this is your first package, you will likely be asked to choose a ‘CRAN mirror’ - select 0 - Cloud
You may then be asked if you would like to create a personal library - select Yes and accept the default folder location
If the package (and it’s dependencies) downloaded you’re all set to continue
If the package failed to download, skip ahead to data.table package again once RStudio is installed
In addition to the data.table package there are several packages every R user needs
To install these packages paste the following lines into R
install.packages(c('installr','devtools','rmarkdown'))
install.packages(c('DT','knitcitations','RefManageR'))
install.packages(c('shiny','RJSONIO','xtable'))
If these packages (and their dependencies) install - you’re all set!
In the previous step you attempted to install the installr package from the CRAN
You can verify that the package installed by running "installr"%in%installed.packages()
If the returned value is TRUE your all set, skip down to 3)
If the returned value is FALSE run install.packages("installr")
If this attempt also fails to install the package skip down to 4)
With the installr package RStudio may be installed from within R by running installr::install_rstudio()
Without the installr package RStudio can be installed from HERE
Once installed, open RStudio to ensure it’s linked with the your installed version of R
With the installr package, Rtools may be installed from within R by running installr::install_rtools()
Without the installr package Rtools can be installed from HERE
After the install completes, run devtools::find_rtools() to ensure R can find Rtools
If this function returns TRUE go on to \(\LaTeX\)
If this function returns FALSE follow the steps below to edit the system path
Perform a search for ‘Environment Variables’
If you have admin rights, choose Edit the System Environment Variables otherwise choose Edit Environment Variables For Your Account
Find the variable Path \(\rightarrow\) click Edit \(\rightarrow\) add c:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin
If the Path variable doesn’t exist or isn’t editable click New \(\rightarrow\) create the variable Path \(\rightarrow\) assign the value c:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin
Once again, run devtools::find_rtools() if this still returns FALSE check the directory in which Rtools is located
With the installr package, MiKTeX may be installed from within R by running installr::install_miktex()
Without the installr package MiKTeX can be installed from HERE
Choose to Install Packages on the Fly
Otherwise accept all the defaults
Once installed, open RStudio and click to create a new file
Choose R Markdown to create a new Rmarkdown file filename.Rmd
In the ‘Document’ dialog choose ‘PDF Document’
Once the demo file opens, click to knit the rmarkdown file into a PDF document
If a pop-up window appears, asking permission to install a \(\LaTeX\) package, check the default location of the package repository and allow the package to install
The first time a document knits into a PDF it can take a minute to install the packages
Go to GitHub.com and sign up for an account
Choose a username
Add an email address (don’t use your afit.edu address as your primary, you can add it as a secondary address later)
Enter a password
After logging in, search for Auburngrads/test-repo to find the test-repo repository created by Auburngrads
On the test-repo page click to fork a copy of the repo to your account
With the installr package, Git may be installed from within R by running installr::install_git()
Without the installr package Git can be installed from HERE
Once the install completes, close and re-open RStudio
Open the ‘Tools’ menu and select ‘Global Options’
In ‘Global Options’ select ‘Git/SVN’
If the ‘Git Executable’ window is blank click ‘Browse’ and navigate to C:\Program Files\Git\bin\bin.exe click OK
If the path to git.exe is already listed in the ‘Git Executable’ window, Git has been installed correctly
Next, we’ll make sure Git is configured
Search your machine for the ‘Git Bash’ application, open the application and type the following two lines
git config --global user.name your.github.username
git config --global user.email your.github.email
Close Git Bash
Finally, let’s set up the SSH connection between RStudio and GitHub
Open ‘Tools’ \(\rightarrow\) ‘Global Options’ \(\rightarrow\) ‘Git/SVN’
Toward the bottom of the ‘Git/SVN’ dialog click ‘Create RSA Key’
After the RSA Key appears click ‘Close’
Click ‘View Public Key’ and copy the text in the window
Return to your GitHub.com account page and click the drop-down arrow next to your account avatar (upper-right corner) \(\rightarrow\) select ‘Settings’
Under ‘Settings’ select ‘SSH and GPG Keys’
Select ‘New SSH Key’ \(\rightarrow\) choose a name for the key, like personal machine
Click and select ‘New Project’
At the menu select ‘Version Control’ and then ‘Git’
Enter the repository url
If you’ve set-up SSH enter the url as git@github.com:your.user.name/test-repo.git
If you have not set up SSH enter the url as https://github.com/your.user.name/test-repo.git
Select ‘OK’ and Git will clone the test-repo to your machine
Once the project opens, edit and commit the changes to the README.md file
Add your initials to the list of initials and save the file
Find the project tabs in the upper-right pane of RStudio
Select the ‘Git’ tab
The README.md file should be listed as a changed file
Click the checkbox next to the filename and then click ‘Commit’
In the Commit dialog, enter a short message in the window detailing the changes you made and click Commit
Now that the changes have been committed they need to be Pushed so that their online counterparts match
Close the Commit dialog and press Push
A window may appear asking for a username and password - ignore this.
After the Push is complete a message will appear indicating that the changes have been syned to the Master branch
Submit a Pull-Request
to sync the changes in your version of test-repo to my version of test-repo
Navigate to the test-repo repository page under your account
Select Pull requests \(\rightarrow\) ‘New Pull Request’
Git will perform a Diff to determine which files have been changed
As only the README.md file is changed between the two repos this should be the only file listed.
Select ‘Create Pull Request’
Once the pull request is finished - so is the process to build R/RStudio toolchain for data science