I have several tables that run frequencies and percentages of my data:
tableAge1 <- table(data$Age)
tableAge2 <- round(prop.table(tableAge1) * 100, 2)
tableGender1 <- table(data$Gender)
tableGender2 <- round(prop.table(tableGender1) * 100, 2)
results:
18-24 25-29 30-34 35-39
2 1 1 2
18-24 25-29 30-34 35-39
15.38 7.69 7.69 15.38
Male Female Not_Answer
3 8 1
Male Female Not_Answer
23.08 69.23 7.69
I want to connect these tables together like so:
18-24 25-29 30-34 35-39 18-24 25-29 30-34 35-39 Male Female Not_Answer
2 1 1 2 15.38 7.69 7.69 15.38 3 8 1
Is there a way to do this?
bind_rows() comes close but adds the data for each categorical variable in a separate line:
> bind_rows(tableAge1, tableAge2, tableGender1)
# A tibble: 3 x 10
`18-24` `25-29` `30-34` `35-39` `40-44` `50-54` `65-69` Female Male `Prefer not to answer`
<table> <table> <table> <table> <table> <table> <table> <table> <table> <table>
1 2.00 1.00 1.00 2.00 2.00 4.00 1.00 NA NA NA
2 15.38 7.69 7.69 15.38 15.38 30.77 7.69 NA NA NA
3 NA NA NA NA NA NA NA 9 3 1