There is another method to subset variables based on index. Suppose we wish to select 1st and 5th thru 10th variables.
Type:
Selecting the first 5 observations.
Type:
Selecting first 5 observations and first 3 variables.
Type:
Finally, let’s try creating a new data frame with FEMALES (SEX = 1) earning more than 35000
# sub-setting based on values of variables
Type:
External resource for subsetting in R: http://www.statmethods.net/management/subset.html