# Subset Example -- subset.r source code. # Load ExamSco data into R. all = read.table("examsco2.txt", header=TRUE) # Print data frame. cat("all data frame:\n") print(all) # Make variables in all available to session so that # all$ prefix is not needed attach(all) # Select only rows where gender="F" and columns # name, midterm, and final. women = all[gender == "F", c("name", "midterm", "final")] # Print subsetted data frame. cat("women data frame:") print(women)