0

My dataframe looks like this: enter image description here

I want to do the following: Select the highest and lowest value in 2020. I also want to add a column that shows the increase in cost from 2007 to 2020 and select the highest and lowest value there.

But when I try:

most_expensive <- university_cost[which.max("2020")]

or

most_expensive <- university_cost[which.max(2020)]

It just returns 50 rows of University names. I have no idea why.

mn2609
  • 53
  • 8
  • Maybe: `university_cost[which.max(university_cost$"2020"),]` ? – GKi Dec 22 '20 at 12:05
  • returns the error that there is an unexpected numerical constant EDIT: Worked, just had to to `university_cost[which.max(university_cost$"2020"),` – mn2609 Dec 22 '20 at 12:06
  • dont post a picture of your data. Instead provide part of your data using `dput(head(mydata))`. Also. provide your desired output. – Cettt Dec 22 '20 at 12:07

0 Answers0