-2

Playing around with airquality, and I want to sort the data by Ozone and Wind (within wind)

I have the following command:

sort.airquality<-airquality[order(Ozone, Wind),]
sort.airquality[1:153,]

For some reason I just don't think this is right, I've tried looking up some of the tutorials but they don't seem to cover exactly what I'm looking for. Any help would be most appreciated.

Thanks.

killahtron
  • 555
  • 1
  • 4
  • 6

2 Answers2

2

You want

sort.airquality <- airquality[order(airquality$Ozone, airquality$Wind),]
Hong Ooi
  • 51,703
  • 12
  • 121
  • 162
2

For improved readability, I suggest

sort.airquality <- airquality[with(airquality, order(Ozone, Wind)),]
Ferdinand.kraft
  • 11,809
  • 7
  • 42
  • 67