4

I have created a table using the ropensci/plotly library. I have tried to add a title several ways.

Here is my code:

library(plotly)
data <- read.csv("data.csv")

plot_ly(

type = 'table',
columnwidth = c(33, 32, 32),
columnorder = c(0, 1, 2),
header = list(
  values = list(list(c("1st column")),
                list(c("2nd column")),
                list(c("3rd column"))
  ),
  align = c("center", "center"),
  line = list(width = 2, color = 'black'),
  fill = list(color = c("blue", "blue")),
  font = list(family = "Arial", size = 14, color = "white")
),
cells = list(
  values = list(c(data$1st_column),c(data$2nd_column),c(data$3rd_column)),
  align = c("center", "center"),
  line = list(color = "black", width = 1),
  font = list(family = "Arial", size = 12, color = c("black"))
))
sectechguy
  • 2,037
  • 4
  • 28
  • 61

1 Answers1

7

I have found that adding:

%>%
layout(title = "Text Title")

to the very end after the last "))" your title will show above your chart.

This is something I was having trouble with and couldn't find an answer for the 'title' chart in R, so I figured I'd post it.

sectechguy
  • 2,037
  • 4
  • 28
  • 61