Jacob Jameson
Summer 2021
You will also have several TAs who will be helping you along the way
Many public policy jobs and the Harris curriculum rely on programming
Why R?
Quantifying the impact of a proposed federal partnership with the company Dollar General to serve as vaccination sites and comparing vaccine access with Dollar General to the current Federal Retail Pharmacy Partnership Program.
Coding Camp:
This is just the beginning of your programming journey!
We will only cover some of it
If you think we are covering too much, also let us know
Video lectures:
Practice in labs (most important part):
Q and A (live session):
Objectives
R Studio is an “integrated development environment” for R.
If you have not already downloaded RStudio– do so now!
Let's Take a tour in Rstudio
We can think of a variable as a container with a name, such as x
, current_temperature
, or subject_id
that contains one or more values. We can create a new variable and assign a value to it using = or ->.
x = 7
x
[1] 7
In the above bit of code, we created a variable called x
and stored the value 7 inside of it.
We can think of a variable as a container with a name, such as x
, current_temperature
, or subject_id
that contains one or more values. We can create a new variable and assign a value to it using = or ->.
my_number <- 5
my_number
[1] 5
In the above bit of code, we created a variable called my_number
and stored the value 5 inside of it.
2 * x
[1] 14
my_number + 5
[1] 10
We can add comments to our code using the # character. It is useful to document our code in this way so that others (and us the next time we read it) have an easier time following what the code is doing.
#my_number is the variable I set equal to 5
my_number - 10
[1] -5
character/string: “a”, “swc”
numeric: 2, 15.5
logical/boolean: TRUE (T), FALSE (F)
special values: missing values (NA), impossible values (NaN), infinity (Inf), etc
-7
7 + 5
7 - 5
7 %% 5
2^4
Inf
is infinity. You can have either positive or negative infinity.
1/0
[1] Inf
2^1234
[1] Inf
NaN
means Not a Number. It's an undefined value.
0/0
[1] NaN
These are also binary operators; they take two objects, and give back a Boolean
7 > 5
7 < 5
7 >= 7
7 <= 5
7 == 5
7 != 5
Warning: == is a comparison operator, = is not!
(5 > 7) & (6 * 7 == 42)
[1] FALSE
(5 > 7) | (6 * 7 == 42)
[1] TRUE
(5 > 7) | (6 * 7 == 42) & (0 != 0)
[1] FALSE
What are the atomic (basic) data types in R?
Will (6 * 10 > 55 ) & (9 != 10-1) | (0 == 1)
return TRUE
?
After going through this video, you should understand how to:
R Markdown is a file format for making dynamic documents with R.
An R Markdown document is written in markdown (an easy-to-write plain text format) and contains chunks of embedded R code, like the document below.