Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion modules/Subsetting_Data_in_R/Subsetting_Data_in_R.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ We are constantly making improvements.
- The sequence `seq()` function helps you create numeric vectors (`from`,`to`, `by`, and `length.out` arguments)
- The repeat `rep()` function helps you create vectors with the `each` and `times` arguments
- Reproducible science makes everyone's life easier!
- `readr`has helpful functions like `read_csv()` that can help you import data into R
- The `readr` package has helpful functions like `read_csv()` that can help you import data into R

📃 [Day 2 Cheatsheet](https://daseh.org/modules/cheatsheets/Day-2.pdf)

Expand Down Expand Up @@ -204,6 +204,14 @@ head(er)

# Renaming Columns

## Why rename?

Renaming can:

- make it easier to work with your data
- make your column names more compaitible with R
- make your column names more interpretable by others

## `rename` function

```{r, fig.alt="dplyr", out.width = "70%", echo = FALSE, fig.align='center'}
Expand Down Expand Up @@ -414,6 +422,20 @@ C. Keeping it as is and use quotes around the column name when you use it.

# Subsetting Columns

## Why Subset?

Subsetting involves grabbing specific parts of your data to:

- Produce a smaller dataset
- Examine specific subsets of your data
- Use a particular part of the data for a specific analysis/visualzation


Be cautious about removing columns/variables as you might find they are useful later.

You should be guided by your questions of interest.


## Let's get our data again

We'll work with the CO heat-related ER visits dataset again.
Expand Down
Loading