Go to the R:/Stats/R/ folder 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
You may be asked if you would like to create a personal library - select Yes and accept the default folder location
If this is your first package, you will likely be asked to choose a ‘CRAN mirror’ - select 0 - Cloud
If the package (and it’s dependencies) downloaded you’re all set to continue
If you get an error message saying that the install location isn’t writable, follow the steps below
Go to C:/Users and open your profile folder
Right-click on the “My Documents” shortcut
Select Properties \(\rightarrow\) Security Tab \(\rightarrow\) Advanced
Select Owner Tab\(\rightarrow\) edit \(\rightarrow\) make yourself the owner \(\rightarrow\) OK
After taking ownership you will likely get a notice, click OK and then close out of the ‘My Documents Properties’ window
Once again, right-click on the “My Documents” shortcut
Select Properties \(\rightarrow\) Security Tab \(\rightarrow\) Advanced
Select Everyone in the top window and then click Change Permissions \(\rightarrow\) check the Allow box for Full control then click OK and then close out of the ‘My Documents Properties’ window
Return to the R console and once more, type install.packages("data.table")
The data.table package (and its dependencies) should begin installing
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'))
Once these packages (and their dependencies) install - you’re all set!
Return to the R:/Stats/R/ folder and download latest version of RStudio
During the installation process, accept all of the defaults
Once installed, open RStudio to ensure it’s linked with the your installed version of R
Rtools is available in the J:\R folder
To connect Rtools follow the steps below to edit the system path
Perform a system search for ‘Environment Variables’
Choose Edit Environment Variables For Your Account
Find the variable Path \(\rightarrow\) click Edit \(\rightarrow\) add J:\R\Rtools\bin;J:\R\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 J:\R\Rtools\bin;J:\R\Rtools\gcc-4.6.3\bin
Run devtools::find_rtools()
\(\LaTeX\) should already be installed on most AFIT machines follow these steps to check
Open C:/Program Files(x86)
Look for a folder MiKTeX 2.9
If this folder is there \(\LaTeX\) is already installed on your machine (go to step 3)
If you do not see this folder, follow the steps below to get \(\LaTeX\) installed
If \(\LaTeX\) isn’t installed, you can install it from the R:/Latex/MikTeX folder
Double click “Complete_Install 2.9.3959” (NOT 2.9.5105)
Follow the prompts for a complete installation
For page size: Letter
For Packages-on-the-fly: Yes
Once MiKTeX installs, open RStudio and click to create a new file
Choose R Markdown to create a new Rmarkdown file *.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, browse to the R:/Latex/packages folder
The first time a document knits into a PDF it can take a minute to install the packages and run the template
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 four lines
git config --global http.proxy http://username@proxyedu1.afit.edu:8080
git config --global https.proxy https://username@proxyedu1.afit.edu:8080
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