Description Usage Arguments Value Note See Also Examples
This function creates a labelled flat table or flat proportional (marginal) table.
1 2 3 4 5 6 7 8 |
data |
A data frame. May also be a grouped data frame (see 'Note' and 'Examples'). |
... |
One or more variables of |
margin |
Specify the table margin that should be computed for proportional
tables. By default, counts are printed. Use |
digits |
Numeric; for proportional tables, |
show.values |
Logical, if |
weights |
Bare name, or name as string, of a variable in |
An object of class ftable
.
data
may also be a grouped data frame (see group_by
)
with up to two grouping variables. Cross tables are created for each subgroup then.
frq
for simple frequency table of labelled vectors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | data(efc)
# flat table with counts
flat_table(efc, e42dep, c172code, e16sex)
# flat table with proportions
flat_table(efc, e42dep, c172code, e16sex, margin = "row")
# flat table from grouped data frame. You need to select
# the grouping variables and at least two more variables for
# cross tabulation.
library(dplyr)
efc %>%
group_by(e16sex) %>%
select(e16sex, c172code, e42dep) %>%
flat_table()
efc %>%
group_by(e16sex, e42dep) %>%
select(e16sex, e42dep, c172code, n4pstu) %>%
flat_table()
# now it gets weird...
efc %>%
group_by(e16sex, e42dep) %>%
select(e16sex, e42dep, c172code, n4pstu, c161sex) %>%
flat_table()
|
sh: 1: wc: Permission denied
sh: 1: cannot create /dev/null: Permission denied
Could not detect number of cores, defaulting to 1.
Learn more about sjmisc with 'browseVignettes("sjmisc")'.
e16sex male female
e42dep c172code
independent low level of education 5 7
intermediate level of education 15 30
high level of education 1 4
slightly dependent low level of education 16 25
intermediate level of education 39 96
high level of education 13 26
moderately dependent low level of education 28 33
intermediate level of education 59 104
high level of education 18 44
severely dependent low level of education 31 34
intermediate level of education 43 120
high level of education 11 39
e16sex male female
e42dep c172code
independent low level of education 41.67 58.33
intermediate level of education 33.33 66.67
high level of education 20.00 80.00
slightly dependent low level of education 39.02 60.98
intermediate level of education 28.89 71.11
high level of education 33.33 66.67
moderately dependent low level of education 45.90 54.10
intermediate level of education 36.20 63.80
high level of education 29.03 70.97
severely dependent low level of education 47.69 52.31
intermediate level of education 26.38 73.62
high level of education 22.00 78.00
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
Grouped by:
elder's gender: male
e42dep independent slightly dependent moderately dependent severely dependent
c172code
low level of education 5 16 28 31
intermediate level of education 15 39 59 43
high level of education 1 13 18 11
Grouped by:
elder's gender: female
e42dep independent slightly dependent moderately dependent severely dependent
c172code
low level of education 7 25 33 34
intermediate level of education 30 96 104 120
high level of education 4 26 44 39
Grouped by:
elder's gender: male
elder's dependency: independent
n4pstu No Care Level Care Level 1 Care Level 2 Care Level 3 Care Level 3+
c172code
low level of education 4 1 0 0 0
intermediate level of education 7 2 4 2 0
high level of education 1 0 0 0 0
Grouped by:
elder's gender: male
elder's dependency: slightly dependent
n4pstu No Care Level Care Level 1 Care Level 2 Care Level 3 Care Level 3+
c172code
low level of education 9 3 1 2 0
intermediate level of education 22 7 8 2 0
high level of education 8 1 2 2 0
Grouped by:
elder's gender: male
elder's dependency: moderately dependent
n4pstu No Care Level Care Level 1 Care Level 2 Care Level 3 Care Level 3+
c172code
low level of education 15 6 4 2 0
intermediate level of education 27 14 13 4 1
high level of education 11 2 5 0 0
Grouped by:
elder's gender: male
elder's dependency: severely dependent
n4pstu No Care Level Care Level 1 Care Level 2 Care Level 3 Care Level 3+
c172code
low level of education 8 5 10 7 0
intermediate level of education 7 3 12 20 1
high level of education 4 2 3 2 0
Grouped by:
elder's gender: female
elder's dependency: independent
n4pstu No Care Level Care Level 1 Care Level 2 Care Level 3 Care Level 3+
c172code
low level of education 3 1 2 1 0
intermediate level of education 19 6 5 0 0
high level of education 2 2 0 0 0
Grouped by:
elder's gender: female
elder's dependency: slightly dependent
n4pstu No Care Level Care Level 1 Care Level 2 Care Level 3 Care Level 3+
c172code
low level of education 17 4 2 1 0
intermediate level of education 63 13 14 4 1
high level of education 18 3 4 1 0
Grouped by:
elder's gender: female
elder's dependency: moderately dependent
n4pstu No Care Level Care Level 1 Care Level 2 Care Level 3 Care Level 3+
c172code
low level of education 16 11 5 1 0
intermediate level of education 44 36 17 7 0
high level of education 22 12 8 2 0
Grouped by:
elder's gender: female
elder's dependency: severely dependent
n4pstu No Care Level Care Level 1 Care Level 2 Care Level 3 Care Level 3+
c172code
low level of education 14 4 8 7 0
intermediate level of education 39 18 35 23 2
high level of education 7 8 16 8 0
Grouped by:
elder's gender: male
elder's dependency: independent
c161sex Male Female
c172code n4pstu
low level of education No Care Level 1 3
Care Level 1 0 1
Care Level 2 0 0
Care Level 3 0 0
Care Level 3+ 0 0
intermediate level of education No Care Level 3 4
Care Level 1 0 2
Care Level 2 1 3
Care Level 3 2 0
Care Level 3+ 0 0
high level of education No Care Level 0 1
Care Level 1 0 0
Care Level 2 0 0
Care Level 3 0 0
Care Level 3+ 0 0
Grouped by:
elder's gender: male
elder's dependency: slightly dependent
c161sex Male Female
c172code n4pstu
low level of education No Care Level 3 6
Care Level 1 1 1
Care Level 2 1 0
Care Level 3 0 2
Care Level 3+ 0 0
intermediate level of education No Care Level 7 15
Care Level 1 2 5
Care Level 2 1 7
Care Level 3 2 0
Care Level 3+ 0 0
high level of education No Care Level 1 7
Care Level 1 0 1
Care Level 2 0 2
Care Level 3 1 1
Care Level 3+ 0 0
Grouped by:
elder's gender: male
elder's dependency: moderately dependent
c161sex Male Female
c172code n4pstu
low level of education No Care Level 7 8
Care Level 1 0 6
Care Level 2 0 4
Care Level 3 0 2
Care Level 3+ 0 0
intermediate level of education No Care Level 3 24
Care Level 1 1 13
Care Level 2 4 9
Care Level 3 1 3
Care Level 3+ 1 0
high level of education No Care Level 5 6
Care Level 1 2 0
Care Level 2 1 4
Care Level 3 0 0
Care Level 3+ 0 0
Grouped by:
elder's gender: male
elder's dependency: severely dependent
c161sex Male Female
c172code n4pstu
low level of education No Care Level 0 8
Care Level 1 1 4
Care Level 2 1 9
Care Level 3 0 7
Care Level 3+ 0 0
intermediate level of education No Care Level 1 6
Care Level 1 0 3
Care Level 2 2 10
Care Level 3 1 19
Care Level 3+ 0 1
high level of education No Care Level 1 3
Care Level 1 2 0
Care Level 2 0 3
Care Level 3 0 2
Care Level 3+ 0 0
Grouped by:
elder's gender: female
elder's dependency: independent
c161sex Male Female
c172code n4pstu
low level of education No Care Level 1 2
Care Level 1 0 1
Care Level 2 0 2
Care Level 3 1 0
Care Level 3+ 0 0
intermediate level of education No Care Level 4 15
Care Level 1 2 4
Care Level 2 2 3
Care Level 3 0 0
Care Level 3+ 0 0
high level of education No Care Level 0 2
Care Level 1 0 2
Care Level 2 0 0
Care Level 3 0 0
Care Level 3+ 0 0
Grouped by:
elder's gender: female
elder's dependency: slightly dependent
c161sex Male Female
c172code n4pstu
low level of education No Care Level 3 14
Care Level 1 0 4
Care Level 2 1 1
Care Level 3 0 1
Care Level 3+ 0 0
intermediate level of education No Care Level 12 51
Care Level 1 3 10
Care Level 2 3 11
Care Level 3 1 3
Care Level 3+ 1 0
high level of education No Care Level 6 12
Care Level 1 0 3
Care Level 2 1 3
Care Level 3 1 0
Care Level 3+ 0 0
Grouped by:
elder's gender: female
elder's dependency: moderately dependent
c161sex Male Female
c172code n4pstu
low level of education No Care Level 6 10
Care Level 1 2 9
Care Level 2 1 4
Care Level 3 0 1
Care Level 3+ 0 0
intermediate level of education No Care Level 8 36
Care Level 1 11 25
Care Level 2 8 9
Care Level 3 0 7
Care Level 3+ 0 0
high level of education No Care Level 7 15
Care Level 1 4 8
Care Level 2 2 6
Care Level 3 0 2
Care Level 3+ 0 0
Grouped by:
elder's gender: female
elder's dependency: severely dependent
c161sex Male Female
c172code n4pstu
low level of education No Care Level 4 10
Care Level 1 2 2
Care Level 2 2 6
Care Level 3 2 5
Care Level 3+ 0 0
intermediate level of education No Care Level 6 33
Care Level 1 3 15
Care Level 2 5 30
Care Level 3 11 12
Care Level 3+ 1 1
high level of education No Care Level 1 6
Care Level 1 2 6
Care Level 2 7 9
Care Level 3 3 5
Care Level 3+ 0 0
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.