0

Crosstable is reporting "Error: Error in argument 'x='. Expecting object of class 'gtsummary'"

It was working earlier, but did an update of packages and it look like the depreciation of as_flextable() in gtsummary 1.3.3 may have broken something. Any suggestions for how to proceed from here?

Using example 1 from https://danchaltiel.github.io/crosstable/#:~:text=Crosstable%20is%20a%20package%20centered,officer%20to%20create%20automatized%20reports.

library(crosstable) ct1 = crosstable(mtcars2, c(disp, vs), by=am, total="both",

  •              percent_pattern="{n} ({p_row}/{p_col})", percent_digits=0) %>%
    
  • as_flextable()
    

Error: ! as_flextable() was deprecated in gtsummary 1.3.3 and is now defunct. ℹ Please use as_flex_table() instead. ℹ The as_flextable() function graduated from 'Experimental' status in v1.3.3. The function's name was changed to avoid a name conflict with flextable::as_flextable(). If you are trying to use the function from {flextable}, for the time being, use the double colon notation when both {gtsummary} and {flextable} are loaded, e.g. flextable::as_flextable(...). Run rlang::last_error() to see where the error occurred.

ct1 Error: object 'ct1' not found

Ok, that made sense, so replaced with as_flex_table() and...

library(crosstable) ct1 = crosstable(mtcars2, c(disp, vs), by=am, total="both",

  •              percent_pattern="{n} ({p_row}/{p_col})", percent_digits=0) %>%
    
  • as_flex_table()
    

Error: Error in argument 'x='. Expecting object of class 'gtsummary'

ct1 Error: object 'ct1' not found

0 Answers0