Error: Can't convert a `flextable` object to function (Bookdown)

I'm working with bookdown. When I build the gitbook, RStudio send me an error: Error: Can't convert a flextable object to function. My code with problem is:

#sd EA debe mostrarse con la cantidad de decimales según las cifras significativas del VE:

# a) Contar las cifras significativas del VE

n<-ve %>% summarise(n()) 
n<-c(n$`n()`)

ve.1<-c(ve$VE)
ve.1<-as.numeric(ve.1)

ve.count <- vector(length=length(ve.1))
for (i in n:1) ve.count[ve.1 == signif(ve.1, i)] <- i
ve.count<-as.numeric(ve.count)

# b) Asignar la cantidad de decimales según las cifras significativas del VE:

df_final_E_1m2<-df_final_E_1m %>% mutate(cedea = mean(round(sd_EA,ve.count)))

cedea<-df_final_E_1m %>% 
  group_by(Parametro) %>% 
  drop_na(Resultado,sd_EA) %>% 
  summarise("sd EA"=mean(round(sd_EA,ve.count)), "sd Rel [%]"= round(mean(`sd EA`)/mean(VE)*100,1))

cedea %>% 
  flextable() %>% 
  compose(part = "header", j = "sd EA", 
          value = as_paragraph("\U03C3", as_sub("EA")))%>% 
  compose(part = "header", j = "sd Rel [%]", 
          value = as_paragraph("\U03C3", as_sub("EA")," [%]"))%>%
  set_header_labels(values = list(Parametro = "Parámetro"))%>% 
  align(j=c(1:3), align="center",part = "all") %>% 
  width(j=c(1,2,3),width=c(1.8,0.4,1))%>%
  bg(part = "header",bg = "#6180C2") %>% 
  color(part = "header",color = "white")

The message of error is:

Quitting from lines 350-384 (BS4_2.Rmd) 
Error: Can't convert a `flextable` object to function
Backtrace:
     x
  1. +-rmarkdown::render_site(output_format = "bookdown::gitbook", encoding = "UTF-8")
  2. | \-generator$render(...)
  3. |   +-xfun::in_dir(...)
  4. |   \-bookdown:::render_book_script(output_format, envir, quiet)
  5. |     \-bookdown::render_book(...)
  6. |       \-bookdown:::render_cur_session(...)
  7. |         \-rmarkdown::render(main, output_format, ..., clean = clean, envir = envir)
  8. |           \-knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
  9. |             \-knitr:::process_file(text, output)
 10. |               +-base::withCallingHandlers(...)
 11. |               +-knitr:::process_group(group)
 12. |               \-knitr:::process_group.block(group)
 13. |                 \-knitr:::call_block(x)
 14. |                   \-knitr:::block_exec(params)
 15. |                     \-knitr:::eng_r(options)
 16. |                       +-knitr:::in_dir(...)
 17. |                       \-knitr:::evaluate(...)
 18. |                         \-evaluate::evaluate(...)
 19. |                           \-evaluate:::evaluate_call(...)
 20. |                             +-evaluate:::timing_fn(...)
 21. |                             +-base:::handle(...)
 22. |                             +-base::withCallingHandlers(...)
 23. |                             +-base::withVisible(eval(expr, envir, enclos))
 24. |                             \-base::eval(expr, envir, enclos)
 25. |                               \-base::eval(expr, envir, enclos)
 26. +-`%>%`(...)
 27. +-flextable::color(., part = "header", color = "white")
 28. +-flextable::bg(., part = "header", bg = "#6180C2")
 29. +-flextable::width(., j = c(1, 2, 3), width = c(1.8, 0.4, 1))
 30. | \-flextable:::get_columns_id(x[["body"]], j)
 31. +-flextable::align(., j = c(1:3), align = "center", part = "all")
 32. +-flextable::set_header_labels(., values = list(Parametro = "Par�metro"))
 33. +-purrr::compose(...)
 34. | +-purrr::map(list2(...), rlang::as_closure, env = caller_env())
 35. | \-rlang::list2(...)
 36. \-purrr::compose(...)
 37.   \-purrr::map(list2(...), rlang::as_closure, env = caller_env())
 38.     \-rlang:::.f(.x[[i]], ...)
 39.       \-rlang::as_function(x, env = env)
 40.         \-rlang:::abort_coercion(x, friendly_type("function"))
Warning messages:
1: In Parametro == c("Aluminio total (Al)", "Ars�nico total (As)",  :
  longitud de objeto mayor no es m�ltiplo de la longitud de uno menor
2: In Parametro == c("Esta�o total (Sn)", "Hierro total (Fe)", "Manganeso total (Mn)",  :
  longitud de objeto mayor no es m�ltiplo de la longitud de uno menor

Ejecuci�n interrumpida

Exited with status 1.

Thank for your help.

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.