When coding demographic information, it is typical to create one variable with multiple categorical values (e.g., ethnicity, college major, occupation). dummy.code
will convert these categories into n distinct dummy coded variables.
If there are many possible values (e.g., country in the SAPA data set) then specifying top will assign dummy codes to just a subset of the data.
If using dummy coded variables as predictors, remember to use n-1 variables.
If group is specified, then all values of x that are in group are given the value of 1, otherwise, 0. (Useful for combining a range of science majors into STEM or not. The example forms a dummy code of any smoking at all.)