Chapter 4 Loading your data
We are still crawling here, but before you can start doing really cool stuff with your data you have got to get the data in R. One of the reasons R is valuable, is that you can “read” all kinds of different files into R. Excel? SPSS? CSV? not a problem.
You will have to load in your data most times. I have learned to be more purposeful in the time I have spent with R and I hope you take that away as well.
Make sure you have the tidyverse
package downloaded. Look at the image below. You will click the install button then type tidyverse. Download the package, then be sure to load it into your markdown file with the library(tidyverse)
command in your first coding block. The video in the coursebook will walk you through things at a comfortable pace. Please give it a try if you’re feeling frustrated. Remember it is week 2.
As you work through this unit I encourage you to keep notes of what you are doing with the #
in your code lines. This is super useful for others and for yourself when you go back to look at something and try to figure out what happened. You also need it for the stackoverflow post this week.
4.1 Goals
Open “stub” files from your class folder
Read in data from .csv files using
read_csv
use
str
,summary
, andhead
to get a quick look at your data framescombine two data frames with
inner_join
practice some debugging
4.2 Tasks
Task 1: Before you start
We will begin today at Chapter 4 of our text and in 4.3 they mention “stubs”. These are .rmd
or R Markdown files located in the zip file you have already downloaded and saved to your desktop. So, as the text says, you don’t need to open a new rmd file, you can just use the ones provided.
Task 2: Loading in your data
Read and complete 4.4 through 4.11.1. This content will take you through “reading” different kinds of files into R so that you can manipulate and work with them. It will also introduce you to one of my favorite functions, inner_join
.
Task 3: Extra Practice, Debugging
4.12 mentioned debugging, or trying to figure out why your code won’t work. This happens a lot! It sucks! However, it reinforces the message that your coding should be purposeful and detailed. I would suggest doing 4.13 for a little practice.
Task 4: Post to Stack Overflow
Choose some code that you worked with in this unit and post that code with the accompanying notes you made about it via the #
. If you do not have this you need to do it. It is good practice explaining to yourself what you are about to do in order to test if you can actually do it. use the hashtag “wk2”.