-6

I'm quite new with all this programming languages and I feel quite lost.

I opened a .csv file in R, where all years are in the same, this is just a chunk of all data:

airportTraffic
Month Passengers.at.London.airports Year.on.year.percentage.change  X
7   1999 July                      10460189                     6.77692529 NA
8    1999 Aug                      10746562                    5.892825629 NA
9   1999 Sept                       9956556                    4.322969061 NA
10   1999 Oct                       9504010                    7.631548966 NA
11   1999 Nov                       7645826                    6.264996409 NA
12   1999 Dec                       7056812                   -0.558869252 NA
13   2000 Jan                       6884793                         Jan-00 NA
14   2000 Feb                       7255968                    8.093845417 NA
15   2000 Mar                       8615850                    2.930832048 NA
16   2000 Apr                       9064285                    10.90525032 NA
17   2000 May                       9390592                    9.099764108 NA
18  2000 June                      10056169                    5.085494433 NA

As all years are in the same file, I would like to know how to get mean for year 1999 and also the rest of the years. I was able to get the mean for all the data, writing:

mean(airportTraffic$Passengers.at.London.airports).

Hope this is understandable.

1 Answers1

0

I use the dplyr package for data frames.

e.g.

library(dplyr)
airportTraffic %>%
group_by(year) %>%
summarise(mean = mean(Passengers.at.London.airports))
iProcrastinate
  • 131
  • 2
  • 7