Skip to content

Instantly share code, notes, and snippets.

@chris-prener
Last active October 17, 2017 19:07
Show Gist options
  • Save chris-prener/ce737d7cfb4c8b1a2ab137c3e89d1349 to your computer and use it in GitHub Desktop.
Save chris-prener/ce737d7cfb4c8b1a2ab137c3e89d1349 to your computer and use it in GitHub Desktop.
SOC 4930 & SOC 5050 - Week 08 - Binary Variable for Examples
library(tidyverse)
mpg %>%
mutate(foreign = ifelse(manufacturer == "audi" |
manufacturer == "honda" |
manufacturer == "hyundai" |
manufacturer == "land rover" |
manufacturer == "nissan" |
manufacturer == "subaru" |
manufacturer == "toyota" |
manufacturer == "volkswagen",
TRUE, FALSE)) %>%
select(manufacturer, model, cty, hwy, foreign) -> autoData
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment