I have created a table in R using Kable. I need to create a heatmap table using formattable()
and provide a table name.
This is the dataset used:
structure(list(Type = c("A", "B", "C", "D"), Count = c(38L, 32L,
13L, 4L), `17-Aug` = c(0.13, -1.09, -1.82, -0.38), `24-Aug` = c(-0.13,
-0.91, -3.62, -1.51), `31-Aug` = c(-6.84, -6.4, -4.84, -1.29),
`07-Sep` = c(-3.31, -0.98, -2.58, 0.8), `14-Sep` = c(-3.24,
-0.87, -3.31, 0.56), `21-Sep` = c(1.47, 2.07, -1.73, 0.73
), `28-Sep` = c(-9.09, -3.33, -3.93, 0.09), `05-Oct` = c(-1.33,
2.96, -0.53, 0.93), `12-Oct` = c(-1.18, 2.8, -0.22, 0.89),
`19-Oct` = c(2.76, 4.33, 0.22, 0.87), `26-Oct` = c(-3.49,
-0.71, -1.47, 0.09), `02-Nov` = c(8.64, 6.98, 3.07, 1.04)), row.names = c(NA,
-4L), class = "data.frame")
I used the following code to create a heat map table:
formattable(df,align = "c", lapply(1:nrow(df), function(row) {
area(row, col = -2) ~ color_tile("white", "mediumaquamarine")
}))
I'm getting a warning message when executing the code:
Warning messages:
1: In gradient(as.numeric(x), ...) : NAs introduced by coercion
2: In gradient(as.numeric(x), ...) : NAs introduced by coercion
3: In gradient(as.numeric(x), ...) : NAs introduced by coercion
4: In gradient(as.numeric(x), ...) : NAs introduced by coercion
Also, I am unable to provide a table name for this table. I looked into this for a solution but I don't get the solution for this.
Can anyone provide a solution for this?
Thanks in advance!!!