I would like to count the number of missing values (NA) in each month and year of the time series (columns) and plot a bar chart.
How to extract this information from a data frame?
I need as result a table with the number of missing values (NA) per month each year, for each columns.
b <- read.table(text = ' Date AAA BBB CCC DDD EEE
49 1999-12-15 24.8 21.4 25.6 35.0 17.4
50 1999-12-16 NA 0.6 1.5 6.3 2.5
51 1999-12-17 NA 16.3 20.3 NA 19.2
52 1999-12-18 13 1.6 NA 6.3 0.0
53 1999-12-19 10 36.4 12.5 26.8 24.9
54 1999-12-20 NA 0.0 0.0 0.2 0.0
55 1999-12-21 0.2 0.0 0.0 0.0 0.0
56 1999-12-22 0.0 0.0 0.0 0.0 0.0')
head(b)
Thank you


You ask two questions, but to address the one in your title, you can count the
NAvalues across columns AAA through EEE by year and month indplyr(note the data are slightly changed to include multiple year-month groups):To create a barplot of this, there are several ways. One way in base R is (note, I saved the above data as
plotdat):Note I changed your sample data to have multiple year-month groups: