davidgohel / flextable

table farming
https://ardata-fr.github.io/flextable-book/
565 stars 82 forks source link

Error for `width()` after `delete_columns()` #602

Closed torden81 closed 10 months ago

torden81 commented 10 months ago

Calling width() on a flextable after columns were deleted with delete_columns() causes an error. For instance,

ft <- flextable::flextable(head(iris)) |>
  flextable::delete_columns(1:3) |>
  flextable::width(width = 4.5)
ft

returns the error message:

Error in data.frame(col_id = x$col_keys, width = x[[part]]$colwidths,  : 
  arguments imply differing number of rows: 2, 5

However, reversing the two commands

ft <- flextable::flextable(head(iris)) |> 
  flextable::width(width = 4.5) |>
  flextable::delete_columns(1:3)
ft

is a success without any errors.

As a user I would expect to be able to apply either approach without errors.


Tested with R v4.3.1 and flextable v0.9.4

davidgohel commented 10 months ago

Can you try with GitHub version? I think it's been fixed recently (and I can't reproduce it while I can with the CRAN version)

torden81 commented 10 months ago

Yes, it works with flextable v0.9.5.008 (c214b8e75aae05b761450c95da377e10f4bac767)

Thank you very much!

github-actions[bot] commented 4 months ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.