Creating a bar graph for panel data

Hello, I have a dataset for 50 American states over 8 years. My variable of interest is dichotomous (0,1). There are some missing values which are entered as 'NA'.

I need to visualise the frequencies for this variable in a combined bar graph for each of the 8 years. I am unable to write the code which will give me a combined graph, while also excluding the 'NA' values.

Any leads would be helpful! TIA

Without the data it's difficult to guess the requirement, best if you could share some data or create some dummy data.

Alternatively, you could try df%>%count(dichotomous, state,year) to get the frequencies including the NA.
and plot via facet_wrap as follows:

count(dichotomous, state,year)%>%
aes(n,state)+ # this will flip the axis so that 50 States could viewed vertically else would not fit on x-axis
facet_wrap(~year) # this will have facets per year. But the 50 States could make plotting tricky.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.