<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="http://www.r-bloggers.com/r-for-publication-by-page-piccinini-lesson-1-r-basics/"></div></div><div><a data-url="http://www.r-bloggers.com/r-for-publication-by-page-piccinini-lesson-1-r-basics/" data-counturl="http://www.r-bloggers.com/r-for-publication-by-page-piccinini-lesson-1-r-basics/" data-count="horizontal" data-text="R for Publication by Page Piccinini: Lesson 1 – R Basics" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://datascienceplus.com/r-for-publication-by-page-piccinini-lesson-1-r-basics/"> DataScience+</a></strong>, and kindly contributed to <a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Before starting this lesson you should have completed all of the steps in <a target="_blank" href="http://datascienceplus.com/r-for-publication-by-page-piccinini-lesson-0-introduction-and-set-up/">Lesson 0</a>. If you have not, go back and do the lesson now.</p>
<p>By the end of this lesson you will be able to:</p>
<blockquote><ul>
<li>Make an R Project.</li>
<li>Commit to Git.</li>
<li>Push to Bitbucket.</li>
<li>Read in and manipulate data.</li>
<li>Make a figure and save it to PDF.</li>
<li>Create an R Markdown document.</li>
</ul>
</blockquote>
<h2>Introduction</h2>
<p>There is a video in end of this post which provides an overview of the lesson and some more detailed explanation of the R code we’ll write below. A PDF of the slides can be downloaded <a target="_blank" href="http://datascienceplus.com/wp-content/uploads/2016/05/rcourse_lesson1.pdf">here</a>. Before beginning please download <a target="_blank" href="http://datascienceplus.com/wp-content/uploads/2016/05/rcourse_lesson1_data.txt">this text file</a>, it is the data we will use for the lesson. We’ll be using some fake picture naming reaction time data from bilinguals and monolinguals. All of the data and completed code for the lesson can be found <a target="_blank" rel="nofollow" href="https://github.com/pagepiccinini/rcourse_lesson1">here</a>.</p>
<h2>Make an R Project</h2>
<p>An R Project is a powerful way to have a self-contained environment for each of your projects. Using Projects also allows us to commit to Git which is a useful method of version control. Before we make a Project though we’re going to start by making our directory that will store everything we’re going to do in RStudio. I’m going to create a folder called “rcourse_lesson1” and then inside of it four folders: 1) “data”, 2) “figures”, 3) “scripts”, and 4) “write_up”. See the example folder below.</p>
<p><a title="" data-rel="lightbox-0" target="_blank" href="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/screen-shot-2016-02-11-at-2-49-33-pm.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/screen-shot-2016-02-11-at-2-49-33-pm-490x313.png?resize=456%2C291 490w, http://datascienceplus.com/wp-content/uploads/2016/05/screen-shot-2016-02-11-at-2-49-33-pm-768x490.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/screen-shot-2016-02-11-at-2-49-33-pm-1024x654.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/screen-shot-2016-02-11-at-2-49-33-pm-600x383.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/screen-shot-2016-02-11-at-2-49-33-pm-300x191.png 300w" alt="screen-shot-2016-02-11-at-2-49-33-pm" class="wp-image-3920" src="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/screen-shot-2016-02-11-at-2-49-33-pm-490x313.png?resize=456%2C291" data-recalc-dims="1"></a></p>
<p>I’m also going to put my data file (“rcourse_lesson1_data.txt”) into my “data” folder so that it looks like below.<br>
<a title="" data-rel="lightbox-1" target="_blank" href="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse1-screenshot2.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse1-screenshot2-490x313.png?resize=456%2C291 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse1-screenshot2-768x490.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse1-screenshot2-1024x654.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse1-screenshot2-600x383.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse1-screenshot2-300x191.png 300w" alt="rcourse1-screenshot2" class="wp-image-3921" src="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse1-screenshot2-490x313.png?resize=456%2C291" data-recalc-dims="1"></a></p>
<p>Okay, we’re now ready to make a Project. To make a new Project, go to the top right hand corner of RStudio and click on where it says “Project: (None)” and then choose “New Project…”. An example screen shot is provided below. I want to quickly note that your RStudio may not look exactly the same as mine. For example, you may have the console in the bottom left hand corner instead of the top right. If you want to change the arrangement of your panes go to “Preferences” → “Pane Layout”.</p>
<p><a title="" data-rel="lightbox-2" target="_blank" href="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot3.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot3-490x328.png?resize=456%2C305 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot3-768x513.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot3-1024x685.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot3-600x401.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot3-300x201.png 300w" alt="rcourse-lesson1-screenshot3" class="wp-image-3922" src="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot3-490x328.png?resize=456%2C305" data-recalc-dims="1"></a></p>
<p>You will be asked if you want to save the current workspace. If you have something important there click “Save”, if you’re not sure click “Save”, otherwise feel free to click “Don’t Save”. A window will then popup asking you how you would like to create your project: 1) “New Directory”, 2) “Existing Directory”, or 3) “Version Control”. See below for an example of what the window should look like.</p>
<p><a title="" data-rel="lightbox-3" target="_blank" href="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot4.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot4-490x328.png?resize=456%2C305 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot4-768x513.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot4-1024x685.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot4-600x401.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot4-300x201.png 300w" alt="rcourse-lesson1-screenshot4" class="wp-image-3924" src="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot4-490x328.png?resize=456%2C305" data-recalc-dims="1"></a></p>
<p>Since we just created our folder structure choose “Existing Directory”. Then use the “Browse…” button to find our root folder. The file path to mine is “~/Desktop/rcourse_lesson1”, as displayed below, since I created my folders on the Desktop. Note, DO NOT browse into one of the sub folders we created (e.g. “data”), be sure to only browse into the main root directory.</p>
<p><a title="" data-rel="lightbox-4" target="_blank" href="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot5.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot5-490x328.png?resize=456%2C305 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot5-768x513.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot5-1024x685.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot5-600x401.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot5-300x201.png 300w" alt="rcourse-lesson1-screenshot5" class="wp-image-3925" src="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot5-490x328.png?resize=456%2C305" data-recalc-dims="1"></a></p>
<p>When you’ve navigated to your folder click “Create Project”. You’ve just successfully created a R Project!</p>
<h2>Commit to Git</h2>
<p>Before beginning any coding we’ll want to make sure that our version control (Git) is set up. To do this go to the top right hand corner that you went to originally to make your project. It should now say the name of your project (for example, mine says “rcourse_lesson1”). Click on it and then choose “Project Options…” as shown below.</p>
<p><a title="" data-rel="lightbox-5" target="_blank" href="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot6.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot6-490x328.png?resize=456%2C305 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot6-768x513.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot6-1024x685.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot6-600x401.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot6-300x201.png 300w" alt="rcourse-lesson1-screenshot6" class="wp-image-3926" src="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot6-490x328.png?resize=456%2C305" data-recalc-dims="1"></a></p>
<p>A window will pop up called “Project Options”. On the left hand side menu choose “Git/SVN” and change the setting of “Version control system” from “(None)” to “Git”. A message will then pop up asking you if you confirm the Git repository, say “Yes”. You will also get a message asking if it is okay to restart RStudio, say “Yes”. You should now see the word “Git” on its side in grey, red, and green in the top menu bar. If you navigate back to the “Git/SVN” page of the “Project Option” it should say “Git”. An example screen shot of the “Project Options” window after you’ve set “Version control system” to “Git” is below.</p>
<p><a title="" data-rel="lightbox-6" target="_blank" href="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot7.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot7-490x328.png?resize=456%2C305 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot7-768x513.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot7-1024x685.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot7-600x401.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot7-300x201.png 300w" alt="rcourse-lesson1-screenshot7" class="wp-image-3927" src="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot7-490x328.png?resize=456%2C305" data-recalc-dims="1"></a></p>
<p>Now that we have Git enabled for our project we should actually commit something. We don’t have much to commit seeing as we have no scripts or figures, but we do have our initial folder structure and the data. To commit to Git click on the sideways “Git” in the menu bar and choose “Commit…”. An example is given below.</p>
<p><a title="" data-rel="lightbox-7" target="_blank" href="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot8.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot8-490x328.png?resize=456%2C305 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot8-768x513.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot8-1024x685.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot8-600x401.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot8-300x201.png 300w" alt="rcourse-lesson1-screenshot8" class="wp-image-3928" src="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot8-490x328.png?resize=456%2C305" data-recalc-dims="1"></a></p>
<p>This should give you a pop up window that lists everything new that hasn’t been committed to Git yet. To commit something either click the box under “Staged” or select an item and then click “Stage” in the top menu. Select everything so that all boxes are checked (as shown below). Finally, write a message in the window for “Commit message”. Generally for my first commit I just write “Initial commit.” as is done below. When you’re ready click “Commit”.</p>
<p><a title="" data-rel="lightbox-8" target="_blank" href="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot9.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot9-490x426.png?resize=456%2C396 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot9-768x668.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot9-1024x890.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot9-600x522.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot9-300x261.png 300w" alt="rcourse-lesson1-screenshot9" class="wp-image-3929" src="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot9-490x426.png?resize=456%2C396" data-recalc-dims="1"></a></p>
<p>You will now see a window that summarizes all of the changes committed to Git, click “Close”. You should notice that the box that previously listed our files is now empty, that’s because you have nothing new to commit. You can now close this window. Good job, you’ve just done your first Git commit!</p>
<h2>Push to Bitbucket</h2>
<p>In addition to committing locally on our personal computer, we’re also going to be pushing our R code up to Bitbucket. When you’re committing to Bitbucket for the first time there are a few steps you need to do. After your first commit though everything will be done directly in RStudio.</p>
<p>Logon to Bitbucket and on the top menu bar choose “Repositories” and then “Create repository”. See example below.</p>
<p><a title="" data-rel="lightbox-9" target="_blank" href="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot10.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot10-490x327.png?resize=456%2C304 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot10-768x512.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot10-1024x683.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot10-600x400.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot10-300x200.png 300w" alt="rcourse-lesson1-screenshot10" class="wp-image-3930" src="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot10-490x327.png?resize=456%2C304" data-recalc-dims="1"></a></p>
<p>On the following page type in the name of your repository in “Repository name”, I chose “R Course: Lesson 1”. Leave everything else as is and click “Create repository”.</p>
<p><a title="" data-rel="lightbox-10" target="_blank" href="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot11.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot11-490x327.png?resize=456%2C304 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot11-768x512.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot11-1024x683.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot11-600x400.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot11-300x200.png 300w" alt="rcourse-lesson1-screenshot11" class="wp-image-3931" src="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot11-490x327.png?resize=456%2C304" data-recalc-dims="1"></a></p>
<p>You should now be on a page like the one below. Under the section for “Command line” click on “I have an existing project”, as we do indeed already have a directory and one initial Git commit. You should see some Terminal code in the box under “Already have a Git repository on your computer? Let’s push it to Bitbucket.” We’ll go through each line now.</p>
<p><a title="" data-rel="lightbox-11" target="_blank" href="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot12.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot12-490x327.png?resize=456%2C304 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot12-768x512.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot12-1024x683.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot12-600x400.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot12-300x200.png 300w" alt="rcourse-lesson1-screenshot12" class="wp-image-3932" src="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot12-490x327.png?resize=456%2C304" data-recalc-dims="1"></a></p>
<p>The first line of the Terminal code</p>
<pre>cd /path/to/my/repo</pre>
<p>is simply telling you to navigate to your root folder we created earlier. If you are on a Unix-like machine open the Terminal and navigate to the root folder (for me it’s “rcourse_lesson1”). If you are on a Windows machine right click on the folder and choose “Git Bash Here”. Another option is to open the Terminal directly from RStudio, go to the “Git” tab, then “More”, and then choose “Shell…”. This will open a Terminal window already in the folder of your project. This should work fine for Unix-like machines but may be less reliable for Windows machines.</p>
<p><a title="" data-rel="lightbox-12" target="_blank" href="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot13.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot13-490x328.png?resize=456%2C305 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot13-768x513.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot13-1024x685.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot13-600x401.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot13-300x201.png 300w" alt="rcourse-lesson1-screenshot13" class="wp-image-3933" src="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot13-490x328.png?resize=456%2C305" data-recalc-dims="1"></a></p>
<p>Once you have navigated to the correct folder copy and paste the second line of the code from Bitbucket into the terminal. Remember, the line below is specific to me and my Bitbucket account. Be sure to copy and paste the code that you see in your browser.</p>
<pre>git remote add origin git@bitbucket.org:pagepiccinini/r-course-lesson-1.git</pre>
<p>The code should run very quickly and you won’t produce an kind of messages. Now copy and paste the third line of code. If this is your first time pushing to Bitbucket you will be asked if you can accept their SSH RSA key, say yes. Also, if you created a passphrase you’ll have to type it in now.</p>
<pre>git push -u origin --all # pushes up the repo and its refs for the first time</pre>
<p>This may take a little bit of time depending on your internet connection, you should be given updates about how far into the upload you are. Finally, copy and paste the last line of code.</p>
<pre>git push -u origin --tags # pushes up any tags</pre>
<p>If everything ran correctly after this line you should get a message that says “Everything up-to-date”. An example Mac Terminal is provided below.</p>
<p><a title="" data-rel="lightbox-13" target="_blank" href="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot14.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot14-490x343.png?resize=456%2C319 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot14-768x538.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot14-1024x718.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot14-600x421.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot14-300x210.png 300w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot14.png 1364w" alt="rcourse-lesson1-screenshot14" class="wp-image-3934" src="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot14-490x343.png?resize=456%2C319" data-recalc-dims="1"></a></p>
<p>You’ve now successfully uploaded your R Project to Bitbucket! To confirm this go back to Bitbucket and refresh the page. The instructions for uploading should now be replaced with a summary of the repository and a history of your past commits on the right hand side. An example screen shot is provided below.</p>
<p><a title="" data-rel="lightbox-14" target="_blank" href="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot15.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot15-490x327.png?resize=456%2C304 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot15-768x512.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot15-1024x683.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot15-600x400.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot15-300x200.png 300w" alt="rcourse-lesson1-screenshot15" class="wp-image-3935" src="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot15-490x327.png?resize=456%2C304" data-recalc-dims="1"></a></p>
<h2>Read in and Manipulate Data</h2>
<p>Now that Git is set up both locally for the project and with Bitbucket we can finally start coding in R. In RStudio go to “File”→ “New File”→ “R Script”. The first thing we’re going to do is read in our data, but even before that we’re going to get ready to read in our data by loading packages. In R the <code>#</code> symbol is used for comments. I generally start all of my code with a comment about loading packages and then load any packages that I need. For this lesson we’ll be using both <code>dplyr</code> and <code>ggplot2</code> Also, if you end a line with four <code>#</code>s it is a code block, and can be collapsed using the small black arrow if you want to only look at a certain part of your code. Start your script by writing and running the code below. To run a particular line of code from a script make sure the cursor is on the line of code you want to run and press Command+Enter on a Mac or Ctrl+Enter on a Linux or Windows machine. To run several lines of code, highlight all the lines you want to run and then press Command+Enter or Ctrl+Enter. You can also click the “Run” button in the top right hand corner of the script. Remember, all of the code fully commented can be found at the link at the top of the lesson.</p>
<pre>## LOAD PACKAGES ####
library(dplyr)
library(ggplot2)</pre>
<p>We can now read in our data. Again I’ll start with a section header comment to note what I’ll be doing in this section and then a sub comment with more specific information about this call. Write the following code and then run it.</p>
<pre>## READ IN DATA AND ORGANIZE ####
# Read in data
data = read.table(&quot;data/rcourse_lesson1_data.txt&quot;, header = T, sep = &quot;t&quot;)</pre>
<p>To read in data we use the <code>read.table()</code> call. For R Projects the working directory is always set to the root folder, so in order to load our data into R we need to first go into the “data” folder and then call the text file, thus our call is “data/rcourse_lesson1_data.txt”. The <code>header = T</code> part of the code let’s R know that the first row of our file includes our variable names, so it should be treated as a header not as a row of data. Finally the <code>sep</code> command is used to tell R what format the data is in. This is a tab delineated file so we set <code>sep</code> to <code>&quot;t&quot;</code>.</p>
<p>Now that we have the data loaded we can look at it. Below are some calls to examine our data such as <code>dim()</code> (which tells us the number of rows and columns), <code>head()</code> (which prints the first six rows), and <code>tail()</code> (which prints the last six rows). I’ve also included an <code>xtabs()</code> call, which is a way to see how many data points are in a given level of a variable. For example, the call here sees how many data points we have in the two levels of “group”, “bilingual” and “monolingual”. Write and run the code below.</p>
<pre># Look at data
dim(data)
head(data)
tail(data)
xtabs(~group, data)</pre>
<p>So far all of this has been basic R code, but now we’re going to use some <code>dplyr</code> code for the first time. Let’s say we want to create a new data frame with only data from our bilinguals. To do this we need to subset out, or filter, “data” to only include bilingual data. We’ll save this to a new data frame called “data_bl”. The code for how to do this is below. For more information on what each part of the code means watch the video or look at the slides at the top of the lesson. Remember, this code will only run if you loaded the <code>dplyr</code> package earlier.</p>
<pre># Subset out bilinguals
data_bl = data %>%
          filter(group == &quot;bilingual&quot;)</pre>
<p>The main thing that may seem strange to you is the <code>%>%</code> code. This is called a “pipe” in <code>dplyr</code> terminology or an infix operator in more general R terminology. It is a way to letting R know that you’re not done writing code. So, R will not execute the code until it gets a line that doesn’t end in <code>%>%</code>. As a result you can stack several <code>dplyr</code> calls in different lines which gives you cleaner, easier to read code. See the video and slides above for an example of adding another <code>filter()</code> call.</p>
<p>We can now look at our new data frame “data_bl” just like we did for “data”. We can see that it has half as many rows as “data” with <code>dim()</code>. Using <code>xtabs()</code> we also see that there are no data points for “group” “monolingual”, which is good since that was our goal with the <code>filter()</code> call. I’ve also added another <code>xtabs()</code> call on the variable “type”. We see that bilinguals are split into two types, “high” and “low”.</p>
<pre># Look at bilingual data
dim(data_bl)
head(data_bl)
tail(data_bl)
xtabs(~group, data_bl)
xtabs(~type, data_bl)</pre>
<p>Now that we’ve done a fair amount of coding it’s a good idea to save our script. Be sure to save the script in the “scripts” folder as shown below. Here I named my script “rcourse_lesson1”.</p>
<p><a title="" data-rel="lightbox-15" target="_blank" href="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot16.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot16-490x390.png?resize=456%2C363 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot16-768x610.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot16-1024x814.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot16-600x477.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot16-300x238.png 300w" alt="rcourse-lesson1-screenshot16" class="wp-image-3936" src="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot16-490x390.png?resize=456%2C363" data-recalc-dims="1"></a></p>
<p>Since we saved our script we’ll also want to commit it to Git. To do this go back to the “Git” menu at the top and choose “Commit…” just like we did for our initial commit. Once again check all of the boxes of changed files and write a message in the “Commit message” window, I wrote “Made script.”. When you are ready click “Commit”.</p>
<p><a title="" data-rel="lightbox-16" target="_blank" href="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot17.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot17-490x426.png?resize=456%2C396 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot17-768x668.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot17-1024x890.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot17-600x522.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot17-300x261.png 300w" alt="rcourse-lesson1-screenshot17" class="wp-image-3937" src="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot17-490x426.png?resize=456%2C396" data-recalc-dims="1"></a></p>
<p>Click “Close” on the message window but don’t close out of the Git window just yet. We’ve committed to Git locally but we haven’t pushed that commit up to Bitbucket. To do that all you have to do is click the button in the top right hand corner that says “Push” with an upwards pointing arrow. You will get a message about the commit. When it is done click “Close” and then close out of the Git window. To confirm that your push to Bitbucket did indeed take place go back to Bitbucket in your browser and refresh the page. You should now see your newest commit with its message in the right hand side of the page as shown below.</p>
<p><a title="" data-rel="lightbox-17" target="_blank" href="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot18.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot18-490x327.png?resize=456%2C304 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot18-768x512.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot18-1024x683.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot18-600x400.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot18-300x200.png 300w" alt="rcourse-lesson1-screenshot18" class="wp-image-3938" src="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot18-490x327.png?resize=456%2C304" data-recalc-dims="1"></a></p>
<p>See how easy that was! All future commits and pushes can also happen directly within RStudio, letting you have both a local and online record of all of your work.</p>
<h2>Make a Figure</h2>
<p>We’ve now gotten some experience with <code>dplyr</code> but none yet with <code>ggplot2</code>, specifically making a figure. We’ll start by making a boxplot of reaction times separated by our two groups. To do this type in and run the code below. Again, I’ve started with a section header and then another sub comment about the plot itself.</p>
<pre>## MAKE FIGURES ####
# By group
data.plot = ggplot(data, aes(x = group, y = rt)) +
            geom_boxplot()
data.plot</pre>
<p>See the video and slides for details of each part of the code. The key features to note are that every plot in <code>ggplot2</code> is initiated with the call <code>ggplot()</code>. We then give it our data frame and set the aesthetics (<code>aes()</code>). On the second line we say what type of plot we’ll be making, in this case a boxplot. Most <code>ggplot2</code> specific plots are made with <code>geom_</code> and then the type of plot to make, in this case <code>boxplot</code>. Also note that for <code>ggplot2</code>, to connect lines of code we use the <code>+</code> operator not the <code>%>%</code> operator. All of this is assigned to “data.plot” and then we call “data.plot” to see the figure.</p>
<p>Right now we only have our plot locally in RStudio. Presumably you’ll want to get a file version of the plot to include in papers or presentations. Below is an updated version of the code to print the plot to a PDF. The first line calls the call <code>pdf()</code>. Note, I want my figure to go into my “figures” folder, so when I give the file path to <code>pdf()</code> I start with <code>figures/</code> before naming the plot “data.pdf”. I then have my plot call and end with <code>dev.off()</code> to close the graphics device pdf(). If you look in the “figures” folder you should now find a PDF of the figure you saw in RStudio.</p>
<pre>## MAKE FIGURES ####
# By group
data.plot = ggplot(data, aes(x = group, y = rt)) +
            geom_boxplot()
pdf(&quot;figures/data.pdf&quot;)
data.plot
dev.off()</pre>
<p>Once again we need to commit our updates to Git and then push to Bitbucket. Go to “Git” in the top menu, “Commit…”, select all modified files, write a commit message (e.g. “Made figure.”), and then click “Commit”. Before closing the window be sure to click “Push” to send it up to Bitbucket. Now when you refresh Bitbucket in your browser you should see your most recent commit.</p>
<p><a title="" data-rel="lightbox-18" target="_blank" href="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot19.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot19-490x327.png?resize=456%2C304 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot19-768x512.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot19-1024x683.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot19-600x400.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot19-300x200.png 300w" alt="rcourse-lesson1-screenshot19" class="wp-image-3939" src="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot19-490x327.png?resize=456%2C304" data-recalc-dims="1"></a></p>
<p>You have successful made a figure, saved it to a PDF, committed your work to Git, and pushed that commit up to Bitbucket. Congrats!</p>
<h2>Create an R Markdown Document</h2>
<p>The final thing we’ll be doing today is creating an R Markdown document to showcase all of our amazing work. The first thing we need to do is save our environment, which has our data, our subsetted data, and our figure. To save the environment be sure you are in the “Environment” tab in RStudio, then click on the figure of the floppy disk to save it. See the screen shot below. A red arrow is pointing to where you should see the floppy disk. Remember though, the “Environment” tap may be in a different pane on your screen.</p>
<p><a title="" data-rel="lightbox-19" target="_blank" href="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot20.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot20-490x328.png?resize=456%2C305 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot20-768x513.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot20-1024x685.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot20-600x401.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot20-300x201.png 300w" alt="rcourse-lesson1-screenshot20" class="wp-image-3940" src="http://i0.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot20-490x328.png?resize=456%2C305" data-recalc-dims="1"></a></p>
<p>Choose your “write_up” folder for where to save the environment and give it a name like I did below such as “rcourse_lesson1_environment”. Press save when ready.</p>
<p><a title="" data-rel="lightbox-20" target="_blank" href="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot22.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot22-490x390.png?resize=456%2C363 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot22-768x610.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot22-1024x814.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot22-600x477.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot22-300x238.png 300w" alt="rcourse-lesson1-screenshot22" class="wp-image-3941" src="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot22-490x390.png?resize=456%2C363" data-recalc-dims="1"></a></p>
<p>Now with our environment saved we can start writing up our results. To make an R Markdown document go to “File” → “New File” → “R Markdown…”. Either now or in a moment you may be asked to install some packages. These are required to create our documents, agree to any package installs. A window will pop up asking for more information. Make sure “Document” is chosen from the right hand side bar (it should be automatically). In “Title” write whatever you want, I’ve chosen “R Course: Lesson 1”. For “Author” it should be your name by default, if not fill in your name. For “Default Output Format” choose “HTML” if it is not already selected. When you’re ready click “OK”.</p>
<p><a title="" data-rel="lightbox-21" target="_blank" href="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot23.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot23-490x328.png?resize=456%2C305 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot23-768x513.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot23-1024x685.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot23-600x401.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot23-300x201.png 300w" alt="rcourse-lesson1-screenshot23" class="wp-image-3942" src="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot23-490x328.png?resize=456%2C305" data-recalc-dims="1"></a></p>
<p>The file will by default have some text pre-added that give examples of how to use R Markdown documents. Feel free to read through it, but when you’re ready delete everything below the following code</p>
<pre>---
title: 'R Course: Lesson 1'
author: &quot;Page Piccinini&quot;
date: &quot;February 11, 2016&quot;
output: html_document
---</pre>
<p>and on the first line below the second set of “—“s type</p>
<pre>```{r}
load(&quot;rcourse_lesson1_environment.RData&quot;)
```</pre>
<p>The use of the <code>```{r}</code> and final  <code>```</code> let’s RStudio know that this part should be read as R code, not as normal text. Any time you type text not inside those commands it well be printed the same way it would be in text file and not read as code. The <code>load()</code> call tells RStudio to read in that environment file we saved earlier. Note, up until now all file paths have been based on the root directory, so why don’t we write <code>write_up/rcourse_lesson1_environment.RData</code>? It’s because RMarkdown documents are special, and their directory is based on where the R Markdown document itself is saved, so we can just directly type the name of the environment file since it will be in the same folder as our R Markdown document.</p>
<p>On the next line we can start writing up our document. Type in the text below:</p>
<pre># Data
Here is a look at our two data frames. First is the one we read in, the second is our subset of just the bilinguals' data.
# Figure
Here's a figure of the bilinguals compared to the monolinguals.</pre>
<p>Note, that this is just regular text, and is not enclosed it our command to be run as R code. Also, while in R scripts the <code>#</code> is used for commenting in Markdown <code>#</code> is used to mark formatting, specifically sections, <code>#</code> is the highest section <code>##</code> a subsection and so forth.</p>
<p>We’re not going to want to just write about our data and figure though, we’re going to want to actually see them. I’ve updated the code to now include two chunks of R code, the first will  display the first few rows of both of our data frames and the second will print our figure. I’ve also added the <code>fig.align='center'</code> call to make sure our figure is centered.</p>
<pre># Data
Here is a look at our two data frames. First is the one we read in, the second is our subset of just the bilinguals' data.
```{r}
head(data)
head(data_bl)
```
# Figure
Here's a figure of the bilinguals compared to the monolinguals.
```{r, fig.align='center'}
data.plot
```</pre>
<p>When you have all of this typed into your R Markdown document click the button that says “Knit HTML”. You will be asked to save the R Markdown document before continuing. Navigate to the “write_up” folder, name your file, and save it. See example below.</p>
<p><a title="" data-rel="lightbox-22" target="_blank" href="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot24.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot24-490x390.png?resize=456%2C363 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot24-768x610.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot24-1024x814.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot24-600x477.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot24-300x238.png 300w" alt="rcourse-lesson1-screenshot24" class="wp-image-3943" src="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot24-490x390.png?resize=456%2C363" data-recalc-dims="1"></a></p>
<p>Press “Save” when ready and it will create your document. You show now have a document something like the one below that.</p>
<p><a title="" data-rel="lightbox-23" target="_blank" href="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot25.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot25-490x419.png?resize=456%2C390 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot25-768x656.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot25-1024x875.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot25-600x513.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot25-300x256.png 300w" alt="rcourse-lesson1-screenshot25" class="wp-image-3944" src="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot25-490x419.png?resize=456%2C390" data-recalc-dims="1"></a></p>
<p>If you want to make a PDF instead of an HTML file simply go back to your R Markdown document and next to where you clicked “Knit HTML” there should be a downward pointing black arrow, click it and choose “Knit PDF”. You can switch back and forth between HTML and PDF as much as you like. Note, if you do not have some kind of Tex installed this will not work. RStudio’s PDF compiler is based on Tex. This should give you a PDF like the one below.</p>
<p><a title="" data-rel="lightbox-24" target="_blank" href="http://i1.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot26.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot26-490x408.png?resize=456%2C380 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot26-768x640.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot26-1024x853.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot26-600x500.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot26-300x250.png 300w" alt="rcourse-lesson1-screenshot26" class="wp-image-3945" src="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot26-490x408.png?resize=456%2C380" data-recalc-dims="1"></a></p>
<p>As always we’re going to want to commit these changes to Git and then push up to Bitbucket. Go to “Git” in the top menu, “Commit…”, select all modified files, write a commit message (e.g. “Made write-up.”), and then click “Commit”. Before closing the window be sure to click “Push” to send it up to Bitbucket. Now when you refresh Bitbucket in your browser you should see your most recent commit.</p>
<p>If you are done with the lesson you can also close the project. It’s important to close projects, otherwise you might start working on a new analysis in an unrelated R Project. To close your project go to the dropdown menu where your project name is written and click “Close Project”. An example screen shot is provided below.</p>
<p><a title="" data-rel="lightbox-25" target="_blank" href="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot27.png"><img sizes="(max-width: 490px) 100vw, 490px" srcset="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot27-490x348.png?resize=456%2C324 490w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot27-768x546.png 768w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot27-1024x728.png 1024w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot27-600x426.png 600w, http://datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot27-300x213.png 300w" alt="rcourse-lesson1-screenshot27" class="wp-image-3946" src="http://i2.wp.com/datascienceplus.com/wp-content/uploads/2016/05/rcourse-lesson1-screenshot27-490x348.png?resize=456%2C324" data-recalc-dims="1"></a></p>
<h2>Conclusion and Next Steps</h2>
<p>We got through a lot today, congrats! You can now do a lot of basic functions in R in a very sophisticated way, and you can summarize you work in a nice document to share with the world. If you want to keep going with this Project look at my full script linked to at the top of the lesson. You’ll see I made a second figure with just the bilinguals and a third figure with a different way to visualize the original data. I also computed some descriptive statistics using <code>dplyr</code>‘s <code>group_by()</code> and <code>summarise()</code> calls. We’ll be using more <code>dplyr</code> code throughout the course, but if you’d like a jump start I highly recommend <a data-rel="nofollow lightbox-video-0" target="_blank" href="https://www.youtube.com/watch?v=8SGif63VW6E">Hadley Wickham’s tutorial at useR 2014</a>. Happy coding!</p>
<ul>
<li><a target="_blank" href="https://www.youtube.com/watch?v=Kwfz_JJyexA">Lesson 1: R Basics</a></li>
</ul>
<p><strong>
<p>Related Post</p>
<p>
<ol>
<li><a title="Permanent Link toR for Publication by Page Piccinini: Lesson 0 – Introduction and Set-up" target="_blank" rel="bookmark" href="http://datascienceplus.com/r-for-publication-by-page-piccinini-lesson-0-introduction-and-set-up/">R for Publication by Page Piccinini: Lesson 0 – Introduction and Set-up</a></li>
<li><a title="Permanent Link toHow to export Regression results from R to MS Word" target="_blank" rel="bookmark" href="http://datascienceplus.com/how-to-export-regression-results-from-r-to-ms-word/">How to export Regression results from R to MS Word</a></li>
<li><a title="Permanent Link toLearn R by Intensive Practice" target="_blank" rel="bookmark" href="http://datascienceplus.com/learn-r-by-intensive-practice/">Learn R by Intensive Practice</a></li>
<li><a title="Permanent Link toLearn R from the Ground Up" target="_blank" rel="bookmark" href="http://datascienceplus.com/learn-r-from-the-ground-up/">Learn R from the Ground Up</a></li>
<li><a title="Permanent Link toTable 1 and the Characteristics of Study Population" target="_blank" rel="bookmark" href="http://datascienceplus.com/table-1-and-the-characteristics-of-study-population/">Table 1 and the Characteristics of Study Population</a></li>
</ol></strong>
<div>
<a target="_blank" href="http://feeds.feedburner.com/~ff/datascienceplus?a=41XG_4QhYQo:tYxwvVSmRQ4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/datascienceplus?i=41XG_4QhYQo:tYxwvVSmRQ4:D7DqB2pKExk" border="0"></a> <a target="_blank" href="http://feeds.feedburner.com/~ff/datascienceplus?a=41XG_4QhYQo:tYxwvVSmRQ4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/datascienceplus?d=qj6IDK7rITs" border="0"></a> <a target="_blank" href="http://feeds.feedburner.com/~ff/datascienceplus?a=41XG_4QhYQo:tYxwvVSmRQ4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/datascienceplus?d=yIl2AUoC8zA" border="0"></a>
</div>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="http://www.r-bloggers.com/r-for-publication-by-page-piccinini-lesson-1-r-basics/"></div></div><div><a data-url="http://www.r-bloggers.com/r-for-publication-by-page-piccinini-lesson-1-r-basics/" data-counturl="http://www.r-bloggers.com/r-for-publication-by-page-piccinini-lesson-1-r-basics/" data-count="vertical" data-text="R for Publication by Page Piccinini: Lesson 1 – R Basics" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://datascienceplus.com/r-for-publication-by-page-piccinini-lesson-1-r-basics/"> DataScience+</a></strong>.</div>
<hr>
<a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="http://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="http://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="http://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="http://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="http://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="http://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="http://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="http://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="http://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="http://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="http://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="http://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="http://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="http://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="http://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="http://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/VUCJrrM9qdM"></a></div>