# Clear the workspace: rm(list = ls()) # Load in the grades from the .csv file on the course website mydata <-read.csv("http://www.courses.washington.edu/psy315/datasets/ExampleGrades.csv") # R's function 'quantile' give you percentile points from percentile ranks. For # Example, here's how get P90, the percentile point for a rank of 90% quantile(mydata\$Grades,.9,type = 5) # Note the option 'type=5'. R allows for 9 different ways for computing percentile # points! They're all very similar. Type 5 is the method described in the # tutorial and is the simplest and most commonly used. # If you want to calculate more than one percentile rank at a time, you can # add a list of ranks using the 'c' command. Remember, 'c' allows you to # concatenate a list of numbers together. # # Let's generate the cutoff percentile points for the grades of A, B, C, D and F. # These correspond to ranks of 90, 80, 70 and 50%. quantile(mydata\$Grades,c(.9,.8,.7,.5),type = 1) # Going the other way, from percentile points to ranks isn't as straightforward # in R. The most recommended way is with the 'ecdf' function ('Emperical Cumulative # Distribution Function'). Here's how to calculate the percentile rank for a point # of 68: ecdf(mydata\$Grades)(68) # You'll notice that 'ecdf' doesn't give you the exact same answers as the method # in the tutorial. That's because it's using a different method for interpolation. # # For large data sets, 'ecdf' will give a number very similar to the method in the # tutorial.