How center the MISSING sign in a cell in a {gt} table

I am building a table with the awesome gt package. I successfully creates a custom value for missing as follows

gt::fmt_missing(      # replace missings
      columns = 2:4,
      missing_text = "N/A"
    )

Now, I want to center this "N/A" in the cells where it appears. I have tried to do this as follows for the column called "network":

gt::tab_style(
    style = gt::cell_text(align = "center"),
    locations = gt::cells_body(
      columns = "network",
      rows = "network" %in% c("N/A")
    )
  )

but that does not seem to do anything. How can I center this "N/A" (or whatever I use for a missing value) in its cell?

I think it should work like that:

gt::tab_style(
    style = gt::cell_text(align = "center"),
    locations = gt::cells_body(
      columns = "network",
      rows = is.na(network)
    )
  )
1 Like

This topic was automatically closed 7 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.