In R, this is an ftable
.
Inputting an ftable
manually is not too difficult if you know how the function works. The data need to be in a format like this:
breathless yes no
coughed yes no
age
20-24 9 7 95 1841
25-29 23 9 108 1654
30-34 54 19 177 1863
If the data are in this format, you can use read.ftable
. For example:
temp <- read.ftable(textConnection("breathless yes no
coughed yes no
age
20-24 9 7 95 1841
25-29 23 9 108 1654
30-34 54 19 177 1863"))
temp
# breathless yes no
# coughed yes no yes no
# age
# 20-24 9 7 95 1841
# 25-29 23 9 108 1654
# 30-34 54 19 177 1863
From there, if you want a "long" data.frame
, with which analysis and reshaping to different formats is much easier, just wrap it in data.frame()
.
data.frame(temp)
# age breathless coughed Freq
# 1 20-24 yes yes 9
# 2 25-29 yes yes 23
# 3 30-34 yes yes 54
# 4 20-24 no yes 95
# 5 25-29 no yes 108
# 6 30-34 no yes 177
# 7 20-24 yes no 7
# 8 25-29 yes no 9
# 9 30-34 yes no 19
# 10 20-24 no no 1841
# 11 25-29 no no 1654
# 12 30-34 no no 1863