###Initialisation des dataframe
#Pour certains dataframe: manque des donnees a partir de 2010 donc on s'arrete a 2009
hist_temp_africa=data.frame(locator="Africa",Year=1901:2009,data=NA)
hist_temp_asia=data.frame(locator="Asia",Year=1901:2009,data=NA)
hist_temp_eur=data.frame(locator="Europe",Year=1901:2009,data=NA)
hist_temp_NoAm=data.frame(locator="North America",Year=1901:2009,data=NA)
hist_temp_SoAm=data.frame(locator="South America",Year=1901:2009,data=NA)
hist_temp_oceana=data.frame(locator="Oceana",Year=1901:2009,data=NA)

# Boucle pour calcul des moyennes annuelles par continent
j=1
for (i in 1901:2009){
  afr=subset(africa.data,africa.data$year==i)
  hist_temp_africa[j,]$data=mean(afr$data)
  
  asi=subset(asia.data,asia.data$year==i)
  hist_temp_asia[j,]$data=mean(asi$data)

  eur=subset(eur.data,eur.data$year==i)
  hist_temp_eur[j,]$data=mean(eur$data)
  
  NoA=subset(NoAm.data,NoAm.data$year==i)
  hist_temp_NoAm[j,]$data=mean(NoA$data)
  
  SoA=subset(SoAm.data,SoAm.data$year==i)
  hist_temp_SoAm[j,]$data=mean(SoA$data)
  
  ocea=subset(oceana.data,oceana.data$year==i)
  ocea=ocea[which(ocea$data!=0),] # dans ce jeu de donnees des valeurs nulles "impossibles donc on supprime
  hist_temp_oceana[j,]$data=mean(ocea$data)
  j=j+1
}
### Plot
hist_temp_world=rbind(hist_temp_africa,hist_temp_asia,hist_temp_eur,hist_temp_NoAm,hist_temp_SoAm,hist_temp_oceana)
ggplot(hist_temp_world,aes(x=Year,y=data,group=locator)) +
  geom_point() +
  geom_path() +
  ylab("Temperature in degree Celsius") +
  labs(title="Average annual temperature")+
  theme_bw() +
  xlab("Year") +
  stat_smooth(se=F,colour="red",lwd=1.5) +
  facet_wrap(~locator,scale="free")