Splitting a Dataset

First, let’s review how to split a dataset: We filter the cases that are relevant for our later analysis. For example, we only want to study male respondents from District 5.

Which functions do we need to apply?

Now filter the dataset for individuals living in District 1 or 12 and working more than 30 hours! Save the subset in a new object!

pssD1D12o30 <- pss %>%
  filter((district == "Distrikt 1" | district == "Distrikt 12") & wkhtot > 30)

head(pssD1D12o30)

Sometimes you may need to merge datasets that were collected separately. You can learn that on the next page. However, feel free to skip the next page if you don’t find it relevant for you!