## Info

Date: Thursday, Oct. 16, 2018

Time: 9:00am - 12:00pm

Location: Young Research Library, West Classroom

Categories: R (programming language)

Calendar: https://calendar.library.ucla.edu/event/4582641

This hands-on workshop will cover basic concepts and tools related to using R in the context of data analysis. Participants will be encouraged to help one another and to apply what they have learned to their own research problems. We’ll cover:

- A basic introduction to R and RStudio
- Visualizing your data with ggplot2, the most popular graphing package in R
- Tidying and transforming data for analysis

You’ll come out of the course with a good foundation on the most important tools in R for working and communicating with data. This course is taught via the tidyverse - a higher level set of packages in R that intends to make it eaier to work with data. You will need to pick up some of the lower level details on R programming as you learn R. See the information below to continue your R education.

## Resources

### Class Materials

- Most materials were taken from the R book Moderndive
- The class Etherpad is here: https://pad.carpentries.org/ucla-intro-r
- My notes can be found here: https://ucla-data-archive.github.io/intro-r-tidyv/

### Basic programming concepts

Use the datacamp tutorials for an intro to basic programming concepts in R.

From the Introduction to R course complete the following chapters. As you work through the chapters, carefully note the important terms and what they are used for. We recommend you do so in a notebook that you can easily refer back to.

- Chapter 1 Intro to basics:
- Console pane: where you enter in commands
- Objects: where values are saved, how to assign values to objects.
- Data types: integers, doubles/numerics, logicals, characters.

- Chapter 2 Vectors:
- Vectors: a series of values.

- Chapter 4 Factors:
*Categorical data*(as opposed to*numerical data*) are represented in R as`factor`

s.

- Chapter 5 Data frames:
- Data frames are analogous to rectangular spreadsheets: they are representations of datasets in R where the rows correspond
*observations*and the columns correspond to*variables*that describe the observations. We will revisit this later in Section \@ref(nycflights13).

- Data frames are analogous to rectangular spreadsheets: they are representations of datasets in R where the rows correspond

- Chapter 1 Intro to basics:
From the Intermediate R course complete the following chapters:

- Chapter 1 Conditionals and Control Flow:
- Testing for equality in R using
`==`

(and not`=`

which is typically used for assignment). Ex:`2 + 1 == 3`

compares`2 + 1`

to`3`

and is correct R syntax, while`2 + 1 = 3`

is not and is incorrect R syntax. - Boolean algebra:
`TRUE/FALSE`

statements and mathematical operators such as`<`

(less than),`<=`

(less than or equal), and`!=`

(not equal to). - Logical operators:
`&`

representing “and”,`|`

representing “or”. Ex:`(2 + 1 == 3) & (2 + 1 == 4)`

returns`FALSE`

while`(2 + 1 == 3) | (2 + 1 == 4)`

returns`TRUE`

.

- Testing for equality in R using
- Chapter 3 Functions:
- Concept of functions: they take in inputs (called
*arguments*) and return outputs. - You either manually specify a function’s arguments or use the function’s
*defaults*.

- Concept of functions: they take in inputs (called

- Chapter 1 Conditionals and Control Flow:

### Tips on learning to code

- Learning to code/program is very much like learning a foreign language
- It can be very daunting and frustrating at first.
- Put in the effort and are not afraid to make mistakes, anybody can learn.