Getting "Error: `x` must be a formula" with qwraps2 summary_table function

getting synonym thesaurus
getting ready
obtaining
is getting a word
get synonym
getting in a sentence
trying to get synonym
i'm getting meaning

I am having trouble creating building the list-of-lists to pass to the summaries argument of summary_table. When I go to use the summary_table function, it returns

"Error: x must be a formula"

summary_test <- list("Gender" = 
     list("Female" = ~ qwraps2::n_perc0(.mydata$sex == "F"),
           "Male" = ~ qwraps2::n_perc0(.mydata$sex == "M")),
  "Age" =
  list("Mean" = ~ qwraps2::mean_sd(.mydata$age, denote_sd = "paren")),
 "Comorbidities" =
   list("HIV Positive" == ~ qwraps2::n_perc0(.mydata$hiv == 1),
        "Type 2 Diabetes" == ~ qwraps2::n_perc0(.mydata$diabetes == 1)))

whole <- summary_table(mydata, summary_test)

can't reproduce without your data, but it looks like you wrote == instead of = in the last list. Try:

summary_test <- list("Gender" = 
                   list("Female" = ~ qwraps2::n_perc0(.mydata$sex == "F"),
                        "Male" = ~ qwraps2::n_perc0(.mydata$sex == "M")),
                 "Age" =
                   list("Mean" = ~ qwraps2::mean_sd(.mydata$age, denote_sd = "paren"),
                        "Comorbidities" =
                          list("HIV Positive" = ~ qwraps2::n_perc0(.mydata$hiv == 1),
                               "Type 2 Diabetes" = ~ qwraps2::n_perc0(.mydata$diabetes == 1)))

whole <- summary_table(mydata, summary_test)

getting, Synonyms for getting at Thesaurus.com with free online thesaurus, antonyms, and definitions. Find descriptive alternatives for getting. getting definition: 1. present participle of get 2. present participle of get . Learn more.

In the end this worked:

summary1 <- list("Age" = 
         list(
           "Mean" = ~ qwraps2::mean_sd(.data$age, digits=1)),
   "Gender" =
       list(
         "Male" = ~ qwraps2::n_perc(.data$sex == "M", digits = 1),
         "Female" = ~ qwraps2::n_perc(.data$sex == "F", digits = 1)),
   "Comorbidities" =
     list(
       "Type 2 Diabetes" = ~ qwraps2::n_perc(.data$diabetes == "1", digits = 1),
       "Past History of PTB" = ~ qwraps2::n_perc(.data$past.ptb == "1", digits = 1),
       "HIV" = ~ qwraps2::n_perc(.data$hiv == "1", digits = 1)
     ))

Getting Synonyms, Getting Antonyms, 261 synonyms of getting from the Merriam-Webster Thesaurus, plus 366 related words, definitions, and antonyms. Find another word for getting. Getting definition: Getting is the present participle of → get 1 . | Meaning, pronunciation, translations and examples

Summaries are to be lists of lists of formulae, that is, the highest level object is a list with each element being a list. The elements of these lower level lists are all to be formulae. The provided summary:

summary_test <- list("Gender" = 
                       list("Female" = ~ qwraps2::n_perc0(.mydata$sex == "F"),
                            "Male"   = ~ qwraps2::n_perc0(.mydata$sex == "M")),
                     "Age" =
                       list("Mean" = ~ qwraps2::mean_sd(.mydata$age, denote_sd = "paren")),
                     "Comorbidities" =
                       list("HIV Positive"    == ~ qwraps2::n_perc0(.mydata$hiv == 1),
                            "Type 2 Diabetes" == ~ qwraps2::n_perc0(.mydata$diabetes == 1)))

has == in the definition for "Comorbidities" and thus logical statements, not formulae.

str(summary_test) 
#> List of 3
#>  $ Gender       :List of 2
#>   ..$ Female:Class 'formula'  language ~qwraps2::n_perc0(.mydata$sex == "F")
#>   .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
#>   ..$ Male  :Class 'formula'  language ~qwraps2::n_perc0(.mydata$sex == "M")
#>   .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
#>  $ Age          :List of 1
#>   ..$ Mean:Class 'formula'  language ~qwraps2::mean_sd(.mydata$age, denote_sd = "paren")
#>   .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
#>  $ Comorbidities:List of 2
#>   ..$ : logi FALSE
#>   ..$ : logi FALSE

Also, the .mydata needs to be replaced with the correct tidyverse data pronoun .data. The correct syntax is:

summary_test <- list("Gender" = 
                       list("Female" = ~ qwraps2::n_perc0(.data$sex == "F"),
                            "Male"   = ~ qwraps2::n_perc0(.data$sex == "M")),
                     "Age" =
                       list("Mean" = ~ qwraps2::mean_sd(.data$age, denote_sd = "paren")),
                     "Comorbidities" =
                       list("HIV Positive"    = ~ qwraps2::n_perc0(.data$hiv == 1),
                            "Type 2 Diabetes" = ~ qwraps2::n_perc0(.data$diabetes == 1)))

str(summary_test)
#> List of 3
#>  $ Gender       :List of 2
#>   ..$ Female:Class 'formula'  language ~qwraps2::n_perc0(.data$sex == "F")
#>   .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
#>   ..$ Male  :Class 'formula'  language ~qwraps2::n_perc0(.data$sex == "M")
#>   .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
#>  $ Age          :List of 1
#>   ..$ Mean:Class 'formula'  language ~qwraps2::mean_sd(.data$age, denote_sd = "paren")
#>   .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
#>  $ Comorbidities:List of 2
#>   ..$ HIV Positive   :Class 'formula'  language ~qwraps2::n_perc0(.data$hiv == 1)
#>   .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
#>   ..$ Type 2 Diabetes:Class 'formula'  language ~qwraps2::n_perc0(.data$diabetes == 1)
#>   .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv>

Created on 2019-11-14 by the reprex package (v0.3.0)

GETTING, getting meaning: 1. present participle of get 2. present participle of get . Learn more. 261 synonyms of getting from the Merriam-Webster Thesaurus, plus 366 related words, definitions, and antonyms. Find another word for getting. Getting: to acquire complete knowledge, understanding, or skill in. Synonyms: learning, mastering, picking up…

Getting definition and meaning, Getting definition: Getting is the present participle of → get 1 . | Meaning, pronunciation Duration: 0:13 Posted: 6 hours ago With all thy getting, get understanding.; That which is got or obtained; gain; profit. 1882, Charlotte Riddell, "Old Mrs Jones", in Weird Stories, page 135 She was always considering how to increase her "gettings," but she never gave a thought as to how she might save them.

GET (verb) definition and synonyms, It's getting late – I have to go. If that spot gets any bigger you should go to the doctor. get wet/cold/tired/ill etc: It was raining and we all got wet. get angry/upset etc� Synonyms for getting in Free Thesaurus. Antonyms for getting. 1 synonym for getting: acquiring. What are synonyms for getting?

Getting Things Done�, David Allen's Getting Things Done� (GTD�) is the work-life management system that alleviates overwhelm, and instills focus, clarity, and confidence.David� get: [verb] to gain possession of. to receive as a return : earn.

Comments
  • May you please provide your dataset or at least a part of it to reproduce your problem? You can use dput(mydata)' Thank you
  • is there a reason you used .mydata instead of .data as is stated in the documentation for summary_table? It also looks like you used == instead of = in your last list.
  • Hi! I solved my problem in the end. Thank you for your replies!