R flextable package behaves differently in local R and Cloud R

I have no issue running below code in my local RStudio.

library(flextable)
img.file <- file.path( R.home("doc"), "html", "logo.jpg" )
library(officer)

myft <- flextable( head(iris))

myft <- compose( myft, i = 1:3, j = 1,
                 value = as_paragraph(
                   as_image(src = img.file, width = .20, height = .15),
                   " blah blah ",
                   as_chunk(Sepal.Length, props = fp_text(color = "red"))
                 ),
                 part = "body")

ft <- autofit(myft)
ft

But on the Cloud R (meaning on Azure, which I install RStudio), the above same code shows the error below:

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

Could anyone help to see what issue causes it?
Thanks.

You must have an object called Sepal.Length in your local environment, that you defined interactively, that is why it doesn't exist in your Azure instance.

pardon my question:
why is it the in local R, there is an object Sepal.Length, but not in Cloud Azure R?
how to check if Sepal.Length exists in the local environment?

I just ran a version of the code in Rstudio cloud, and it ran fine
my only change was to omit the img file logo (which I dont have)

library(flextable)

library(officer)

myft <- flextable( head(iris))

myft <- compose( myft, i = 1:3, j = 1,
                 value = as_paragraph(
                   " blah blah ",
                   as_chunk(Sepal.Length, props = fp_text(color = "red"))
                 ),
                 part = "body")

ft <- autofit(myft)
ft

perhaps your session got into a bad state. I recommend you restart it (Control + Shift + F10)

SPLENDID. It works now.
Control+Shift+F10 is the magic.
Thank you very much.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.