# Create a vector of race scoresrace<-c("White","Black","Asian","Hispanic","Other")# Generate random income values for each race (100 cases)set.seed(123)# for reproducibilityincome<-round(runif(100,min=20000,max=100000),digits=2)# Repeat each race 20 times to get 100 casesrace<-rep(race,each=20)# Combine race and income into a data framedata<-data.frame(race,income)# Print the first few rows of the datasetprint(head(data))
## race income
## 1 White 43006.20
## 2 White 83064.41
## 3 White 52718.15
## 4 White 90641.39
## 5 White 95237.38
## 6 White 23644.52
Create Dummy Variables
data<-data%>%dummy_cols(select_columns="race")
Regress Income on Race (African Americans as the Reference Category)