atorus-research/CDISC_pilot_replication

Error: is_huxtable(x = ht) is not TRUE

Closed this issue · 3 comments

getting this error.

# Write into doc object and pull titles/footnotes from excel file
doc <- rtf_doc(ht) %>% titles_and_footnotes_from_df(
  from.file='./data/titles.xlsx',
  reader=example_custom_reader,
  table_number='14-2.01') %>%
  set_font_size(10) %>%
  set_ignore_cell_padding(TRUE) %>%
  set_column_header_buffer(top=1)

is_huxtable_error

Hi @datascientist999-hub!

It looks like the object ht isn't a huxtable table. This can happen sometimes if you're not executing the program in order. Prior to executing the section that you highlighted, did you run the code from t-14-1-02.R starting at line 129:

ht <- combinedTable %>%
  huxtable::as_hux(add_colnames=TRUE)

huxtable::bottom_border(ht)[1, ] <- 1
huxtable::bold(ht)[1, ] <- TRUE
huxtable::align(ht)[1, ] <- 'center'
huxtable::align(ht)[, 6] <- "center"
huxtable::width(ht) <- 1.5
huxtable::escape_contents(ht) <- FALSE
huxtable::col_width(ht) <- c(.4, .12, .12, .12, .12, .12)
huxtable::bottom_padding(ht) <- 0
huxtable::top_padding(ht) <- 0
huxtable::valign(ht)[1,] <- "bottom"
ht[8,2] <- ""
ht <- huxtable::merge_cells(ht, 8, 1:2)

If this still doesn't work, I would need to see your session info (gathered with the function sessionInfo()) to understand if there's some sort of potential dependency issue.

Please let us know if this resolves your problem!

@atorus-research Thank you, this is very useful package for pharma!

I had executed prior code with ht as huxtable table successfully.

I realized I had library(huxtable) after library(pharmaRTF). Flipped the order and the problem is resolved now.

fyi - following is my order now:

library(glue)
library(huxtable)
library(tidyverse)
library(haven)
library(assertthat)
library(pharmaRTF)
library(readxl)
library(magrittr)

Thanks for listing your solution! This makes sense - pharmaRTF has namespace conflicts with huxtable. We're brainstorming some ways to make this clear to users.