How to customize rhandsontable headers in R?

548 Views Asked by At

I want to customize a rhandsontable header starting from this data.frame:

DF <-
  data.frame(
    Qty1 = rnorm(72, mean = 40, sd = 10),
    Price1 = rnorm(72, mean = 30, sd = 10),
    Qty2 = rnorm(72, mean = 40, sd = 10),
    Price2 = rnorm(72, mean = 30, sd = 10),
    Zone = rep(c("NORTH", "SOUTH", "WEST"), each = 24)
  )

This is what I was able to achieve so far:

library(rhandsontable)
rhandsontable(DF, width = 600, height = 300) %>%
  hot_col(c("Price1", "Price2"), format = "$0,0.00")

enter image description here

While this is what I'm trying to achieve:

enter image description here

Within R, how do I:

  • Customize the header to achieve the result in the picture above?

Any help would be appreciated. Thanks.

1

There are 1 best solutions below

2
Albert Hofstetter On

What I did was to hide the headers. Instead I added an extra row at the top of my data frame with the header values. For this row you can then use merged columns in rhandsontable. You can then also disable edits for this row.