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.
Hi,
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:
df%>%
count(dichotomous, state,year)%>%
ggplot()+
aes(n,state)+ # this will flip the axis so that 50 States could viewed vertically else would not fit on x-axis
geom_col()+
facet_wrap(~year) # this will have facets per year. But the 50 States could make plotting tricky.