I have a data frame called stats with two columns Gender and Transportation.used as shown below:
Gender    Transportation.used
Male      Bus
Male      Car
Female    Car
Male      Car
Male      Motorcycle
Female    Bus
and the list go on.. (or view here: https://i.stack.imgur.com/GROIi.jpg)
data_stats <- read.table(text="Gender   Transportation.used
Male    Bus
Male    Car
Female  Car
Male    Car
Male    Motorcycle
Female  Bus
Female  Bus
Female  Bus
Female  Bus
Male    Car
Female  Car
",header=T)
What I wanna do is to calculate the frequency for gender based on the selected transport. I will need the data later on to plot a percentage bar graph. Desired output as below:
          Male    Female
   Bus    1        4
So how do I calculate in order to get the data? I'm still a beginner in using R, please do help me. Thanks in advance!
 
     
     
     
    