Closed rkcatipon closed 4 years ago
Response from instructors:
Deblina
Hey Regina! This is a great question, and yes, issues on Github are the best place for similar questions. As a first pass, though, I'd say that row_number() gives something akin to an index of a vector. In the example code, then, we've arranged the dataframe according to cost, and then used the row_number() function to assign an index to each row (subtracting one because UChicago cannot be cheaper than itself). We then have this column, school_cheaper, that gives a kind of global sense of how expensive a school is. This is just a first glance explanation, so any mistakes are totally my fault. I'd be happy to get more into this on Github, where the rest of the class can also weigh in/benefit. Best, Deb
Dr. Soltoff
Correct. Row_number() is function to rank order rows based on their values for specified variables. It is not the only method. Check the documentation for examples of other functions with similar goals but different approaches for a comparison.
Thanks, Benjamin
I had a follow-up question from today's class exercise regarding these lines of code:
Specifically, I do not understand how row_number() ranks vectors. The example from the book has:
But it's not clear to me what is happening here.