0
I have a dataframe with 25 people and their respective ages from 2012 to 2015, but in a few years the ages were not filled.
id<-c(1:25)
idade_2012<-c(21, 18, 19, 25, 20, 12, 12, 13, 14, 29, 40, 11, 15, 14, 24, 16, 14, 12, 13, 14, 12, 21, 14, 16, 13)
idade_2013<-c(22, NA, 20, NA, NA, 13, 13, 14, 15, 30, 41, 12, 16, 15, 25, NA, 15, 13, 14, 15, 13, 22, 15, NA, NA)
idade_2014<-c(NA, NA, NA, NA, NA, NA, 14, 15, 16, 31, NA, 13, 17, 16, 26, 18, NA, 14, 15, NA, 14, 23, 16, NA, NA)
idade_2015<-c(NA, NA, NA, 28, NA, 15, 15, 16, 17, NA, NA, 14, NA, 17, 27, 19, NA, 15, 16, NA, NA, 24, 17, NA, 16)
df<-data.frame(id, idade_2012, idade_2013, idade_2014, idade_2015)
df
Yes, but in some cases I do not have 2012, 2013, 2014, so with this script would not work.
– Tadeu