Lubridate and Categorical Variables


I am curious if you can look at certain variables in a dataset based of trends such as 53 Males were tested for the Flu in November?

With my particular data, there is a column titled "Session.Date" and will list every date a test was conducted.

I usually start with lubridate and will run this code to get things going:
Session_Date2 <- mdy(Aphirm_Jan_to_October$Session.Date)

From here I look at testing trends by month, day or year.

table(month(Session.Date2, label = TRUE))

Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
138 196 64 3 0 8 18 26 31 20 0 0

My question is, how (or is there a way) that I can look at testing rates per month with combining this and lets say Gender Group or Priority Populations?

Example: There were 138 people tested in Jan, and with Gender Group (Male, Female) provide that breakdown.

Is there a way to do this?

For example, this is the best I can come up with right now.

Session.Date Female Male Transgender
1/13/2020 2 8 0
1/14/2020 0 1 0
1/16/2020 5 6 0
1/17/2020 3 1 0
1/2/2020 2 10 0
1/20/2020 3 14 0
1/21/2020 7 1 0
1/22/2020 0 1 0
1/23/2020 0 3 0
1/24/2020 2 2 0
1/27/2020 4 7 0

Thank you,

See the FAQ: How to do a minimal reproducible example reprex for beginners. Having to reverse engineer the issue deters answers.

table(x, y) would give a contingency of X by y if that is what you are looking for?

I'm thinking you would benefit from general info on summarising by groups using tidyverse methods.
You could study this and surrounding chapters.
5 Data transformation | R for Data Science (

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.