O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting ready

If you have not already downloaded the files for this chapter, do so now and ensure that the college-perf.csv file is in your R working directory. The file has data about a set of college students. The Perf variable has their college performance classified as High, Medium, or Low. The Pred variable contains a classification model's predictions of the performance level. The following code reads the data and converts the factor levels to a meaningful order - by default, R orders factors alphabetically:

> cp <- read.csv("college-perf.csv") 
> cp$Perf <- ordered(cp$Perf, levels =  
+             c("Low", "Medium", "High")) 
 
> cp$Pred <- ordered(cp$Pred, levels =  
+             c("Low", "Medium", "High")) 

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required