library(poliscidata) # run every time
# Creating a numeric indicator variable
gss$veteran = gss$vetyears != "NONE" # Any years of service yields TRUE
gss$veteran = as.numeric(gss$veteran) # TRUE and FALSE values now 1s and 0s
# the freq dist tables not strictly necessary but you should check your work
cat("Frequency Distribution Table (Original Variable):\n")
freq(gss$vetyears, plot=F) # Make sure indicator variable correct
cat("\nFrequency Distribution Table (New Variable):\n")
freq(gss$veteran, plot=F) # by comparing frequencies