rformattable

Having trouble aligning data using formattable in R


I put my data into a data frame and now want to align the data.

df.obs <- data.frame(Observer_Unanimous, row.names = TRUE)

Basic formattable plot

I now want to left align the first column (header), and center align the next three.

Code run:

formattable(df.obs, align = c("1", "c", "c", "c")) 

**Error in kable(mat, format = format, align = align, escape = FALSE, ...,  : 
  'align' must be a character vector of possible values 'l', 'r', and 'c'**

Not making progess! Any thoughts?


Solution

  • If we directly apply formattable on the data.frame, it would work

    library(formattable)
    df1 <- head(iris)
    formattable(df1, align = c("l", "c", "c", "c", "r"))
    

    -output

    enter image description here