davidgohel / flextable

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

Error in running the example code of as_image #567

Closed FarinBach closed 1 year ago

FarinBach commented 1 year ago

Hi! I am trying to run the example code in R( R studio version: 2023.06.1+524; R version: 4.2.1; flextable version: 0.9.2):

img.file <- file.path( R.home("doc"),
  "html", "logo.jpg" )
if (require("magick")) {
  myft <- flextable( head(iris))
  myft <- compose( myft, i = 1:3, j = 1,
   value = as_paragraph(
     as_image(src = img.file),
     " ",
     as_chunk(Sepal.Length,
       props = fp_text_default(color = "red"))
   ),
   part = "body")
  ft <- autofit(myft)
  ft
}

And then i meet an error:

Error in as_chunk(Sepal.Length, props = fp_text_default(color = "red")) : 
  object 'Sepal.Length' not found

So are there something wrong? What should I do? Thank you!

davidgohel commented 1 year ago

Cross-posted here: https://stackoverflow.com/questions/76989902/error-in-running-the-example-code-of-as-image and no sessionInfo() is provided as asked when submitting an issue. As it is also not reproducible, my only guess is you loaded 'purrr' and the function compose being used is the one of 'purrr', use mk_par instead, you can read the doc (?compose) to get more info about this.

FarinBach commented 1 year ago

Cross-posted here: https://stackoverflow.com/questions/76989902/error-in-running-the-example-code-of-as-image and no sessionInfo() is provided as asked when submitting an issue. As it is also not reproducible, my only guess is you loaded 'purrr' and the function compose being used is the one of 'purrr', use mk_par instead, you can read the doc (?compose) to get more info about this.

Yes! It works!! Thank you!

github-actions[bot] commented 9 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.