Is there a package in R to generate a tabulation similar to the SPSS output in the attached picture. The crosstabulation involve 4 variables. 1 variable in the row and 3 other variables in the columns at the same level. Only total is tabulated in counts while others are in percentages. I have also attached the example of the data structure. q0003 is in the row while q0001, q0004 and q0005 are in the columns. And below is the sample data to play with
q0001 <- c(1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
q0003 <- c(1,4,1,1,2,1,1,4,1,3,1,3,1,1,2,1,1,2,1,2)
q0004 <- c(1,4,8,5,2,1,1,4,1,3,1,3,6,1,2,1,7,2,1,8)
q0005 <- c(1,4,1,1,2,5,1,4,1,3,1,3,5,1,2,1,6,2,1,6)
q0001 <- ordered(q0001, levels=c(1:2), labels=c("Consultant gynaecologist", "Senior Registrar in gynaecology"))
q0003 <- ordered(q0003, levels=c(1:4), labels=c("Has interest in endoscopy but yet to achieve competence in diagnostic procedures", "Can perform diagnostic procedures but not operative", "Can perform minor and intermediate operative procedures","Can perform advanced procedures"))
q0004 <- ordered(q0004, levels=c(1:8), labels=c("None","Basic Certificate Course in Nigeria","Basic Certificate Course outside Nigeria (e.g. FMAS)","Advanced Certificate Course in Nigeria","Advanced certificate Course outside Nigeria (e.g. DMAS)", "Euro Bachelors in Endoscopy", "Masters in Endoscopy (e.g. MMAS)","Post Fellowship training in Endoscopy or Reproductive surgery"))
q0005 <- ordered(q0005, levels=c(1:6), labels=c("Less than 5", "6-10","11-20", "21-30", "31-40", "More than 40"))
data<- data.frame(q0001,q0003,q0004, q0005)
And I finally have the complete data with Dput below
dataEx <- structure(list(ID = 1:141, q0003 = structure(c(1L, 4L, 3L, 1L,
2L, 1L, 3L, 2L, 1L, 2L, 2L, 3L, 3L, 1L, 3L, 3L, 2L, 3L, 3L, 2L,
3L, 3L, 2L, 3L, 3L, 2L, 2L, 3L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L,
3L, 4L, 1L, 3L, 2L, 2L, 3L, 4L, 3L, 2L, 4L, 2L, 4L, 2L, 3L, 1L,
2L, 1L, 3L, 2L, 3L, 2L, 4L, 3L, 2L, 4L, 2L, 3L, 1L, 3L, 2L, 2L,
3L, 1L, 4L, 2L, 2L, 3L, 3L, 3L, 3L, 1L, 3L, 3L, 1L, 2L, 2L, 2L,
3L, 3L, 1L, 3L, 3L, 4L, 1L, 2L, 3L, 3L, 4L, 3L, 2L, 4L, 2L, 4L,
3L, 4L, 3L, 4L, 4L, 3L, 2L, 3L, 3L, 3L, 3L, 1L, 4L, 4L, 3L, 2L,
2L, 3L, 2L, 2L, 3L, 3L, 4L, 2L, 3L, 3L, 2L, 2L, 3L, 1L, 1L, 4L,
3L, 2L, 4L, 3L, 2L, 2L, 4L, 2L, 2L), .Label = c("Can perform advanced procedures",
"Can perform diagnostic procedures but not operative", "Can perform minor and intermediate operative procedures",
"Has interest in endoscopy but yet to achieve competence in diagnostic procedures"
), class = "factor"), q0001 = structure(c(2L, 2L, 2L, 2L, 3L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 2L, 2L, 2L,
2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L,
2L, 2L, 2L, 2L, 3L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("", "Consultant gynaecologist",
"Senior Registrar in gynaecology"), class = "factor"), q0004 = structure(c(6L,
7L, 3L, 8L, 7L, 3L, 4L, 7L, 6L, 7L, 7L, 3L, 4L, 8L, 5L, 3L, 4L,
3L, 4L, 4L, 5L, 4L, 5L, 5L, 2L, 7L, 4L, 4L, 8L, 6L, 3L, 4L, 3L,
4L, 4L, 4L, 4L, 7L, 3L, 5L, 7L, 4L, 3L, 4L, 6L, 4L, 4L, 3L, 7L,
4L, 2L, 3L, 3L, 8L, 3L, 4L, 2L, 7L, 7L, 1L, 7L, 7L, 7L, 3L, 8L,
5L, 5L, 4L, 5L, 3L, 4L, 4L, 4L, 3L, 3L, 5L, 5L, 8L, 8L, 2L, 3L,
3L, 4L, 3L, 3L, 7L, 2L, 4L, 3L, 5L, 3L, 2L, 4L, 3L, 4L, 2L, 7L,
7L, 4L, 7L, 3L, 4L, 3L, 4L, 4L, 8L, 4L, 2L, 2L, 8L, 3L, 3L, 4L,
4L, 5L, 7L, 5L, 3L, 2L, 4L, 3L, 5L, 7L, 3L, 5L, 3L, 4L, 7L, 3L,
6L, 8L, 7L, 4L, 2L, 4L, 4L, 4L, 4L, 4L, 7L, 7L), .Label = c("",
"Advanced Certificate Course in Nigeria", "Advanced certificate Course outside Nigeria (e.g. DMAS)",
"Basic Certificate Course in Nigeria", "Basic Certificate Course outside Nigeria (e.g. FMAS)",
"Euro Bachelors in Endoscopy", "None", "Post Fellowship training in Endoscopy or Reproductive surgery"
), class = "factor"), q0005 = structure(c(2L, 5L, 3L, 4L, 4L,
4L, 5L, 4L, 2L, 5L, 5L, 4L, 4L, 3L, 4L, 5L, 5L, 5L, 4L, 2L, 5L,
4L, 5L, 5L, 5L, 5L, 5L, 2L, 2L, 3L, 4L, 5L, 4L, 5L, 5L, 5L, 5L,
5L, 5L, 4L, 5L, 5L, 5L, 5L, 4L, 5L, 5L, 5L, 5L, 5L, 2L, 4L, 5L,
4L, 4L, 5L, 2L, 5L, 5L, 3L, 5L, 1L, 4L, 5L, 2L, 5L, 5L, 5L, 5L,
2L, 5L, 5L, 5L, 4L, 4L, 5L, 2L, 6L, 4L, 5L, 4L, 5L, 5L, 5L, 5L,
5L, 4L, 5L, 5L, 1L, 5L, 5L, 4L, 4L, 5L, 5L, 1L, 5L, 4L, 5L, 2L,
1L, 5L, 5L, 5L, 5L, 5L, 4L, 4L, 5L, 4L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 4L, 4L, 4L, 1L, 5L, 2L, 5L, 5L, 4L, 5L, 3L, 4L, 5L, 2L,
5L, 5L, 4L, 5L, 1L, 5L, 5L, 5L), .Label = c("", "11-20", "21-30",
"6-10", "Less than 5", "More than 40"), class = "factor")), class = "data.frame", row.names = c(NA,
-141L))