strengejacke / sjmisc

Data transformation and utility functions for R

Home Page:https://strengejacke.github.io/sjmisc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

frq fails when used for more than 1 variable and after `dplyr::group_by`

iago-pssjd opened this issue · comments

For example:

efc %>%
 	group_by(c172code) %>%
 	frq(is.na(nur_pst), c161sex)
New names:
* c172code -> c172code...1
* c172code -> c172code...3

carer's level of education (c172code...1) <numeric>
# total N=908  valid N=842  mean=1.97  sd=0.63

Value |                           Label |   N | Raw % | Valid % | Cum. %
------------------------------------------------------------------------
    1 |          low level of education | 180 | 19.82 |   21.38 |  21.38
    2 | intermediate level of education | 506 | 55.73 |   60.10 |  81.47
    3 |         high level of education | 156 | 17.18 |   18.53 | 100.00
 <NA> |                            <NA> |  66 |  7.27 |    <NA> |   <NA>


is.na(nur_pst) <lgl>
# total N=908  valid N=908  mean=0.46  sd=0.50

Value |   N | Raw % | Valid % | Cum. %
--------------------------------------
FALSE | 489 | 53.85 |   53.85 |  53.85
TRUE  | 419 | 46.15 |   46.15 | 100.00
<NA>  |   0 |  0.00 |    <NA> |   <NA>


carer's level of education (c172code...3) <numeric>
# total N=908  valid N=842  mean=1.97  sd=0.63

Value |                           Label |   N | Raw % | Valid % | Cum. %
------------------------------------------------------------------------
    1 |          low level of education | 180 | 19.82 |   21.38 |  21.38
    2 | intermediate level of education | 506 | 55.73 |   60.10 |  81.47
    3 |         high level of education | 156 | 17.18 |   18.53 | 100.00
 <NA> |                            <NA> |  66 |  7.27 |    <NA> |   <NA>


carer's gender (c161sex) <numeric>
# total N=908  valid N=901  mean=1.76  sd=0.43

Value |  Label |   N | Raw % | Valid % | Cum. %
-----------------------------------------------
    1 |   Male | 215 | 23.68 |   23.86 |  23.86
    2 | Female | 686 | 75.55 |   76.14 | 100.00
 <NA> |   <NA> |   7 |  0.77 |    <NA> |   <NA>