rain<-read.csv("csvrainfall.csv")
temp<- read.csv("temp.csv")
mean_temp<-temp$Temp
rain$mean_ann_rain<- apply(rain[,-1], 1, function(x) mean(x, na.rm=TRUE)) # mean of rain of a year
combined_rain_temp<- cbind(rain, mean_temp) # combining datasets
long_combined<- melt(combined_rain_temp, id.vars = c("Time", "mean_ann_rain", "mean_temp"), variable.name = "Region", value.name = "Rainfall") # from wide to long form
ggplot(long_combined, aes(x=mean_ann_rain, y= mean_temp))+ geom_point()+ labs(title = 'Year:{frame_time}', x="Mean annual rainfall", y="Mean annual temperature")+
transition_time(Time)+ ease_aes('linear')+ shadow_wake(.03)
Created on 2023-06-06 with reprex v2.0.2
There is no error, the code generated the .png files, just there is no graph showing. here is small part of two datasets.
Time | Temp |
---|---|
1951 | 24.22 |
1952 | 24.34 |
1953 | 24.57 |
1954 | 24.13 |
1955 | 23.97 |
1956 | 23.96 |
Time | Andaman and Nicobar Islands | Assam and Meghalaya |
---|---|---|
1951 | 3275.1 | 2613.8 |
1952 | 3079.9 | 2851.3 |
1953 | 2721.9 | 2559.9 |
1954 | 3449 | 2859.1 |
1955 | 3349.6 | 2761.2 |
1956 | 3080 | 2802.9 |