I want a interactive line graph in R shiny where the points have shape and color determined by the value of PKPTMI. My code is:
library(shiny)
library(ggplot2)
library(plotly)
ui <- fluidPage(
titlePanel(“renderPlotly with ggplot”),
mainPanel(
plotlyOutput(“plot2”)))
server <- function(input, output) {
output$plot2 <- renderPlotly({
ggplot(rand203, aes(x = PKPTMS, y = PKCNCN,
shape = as.factor(PKPTMI),
fill = as.factor(PKPTMI), group=1)) +
geom_line() +
geom_point(size = 2.5)
})}
shinyApp(ui, server)
But the graph doesn’t display a continuous line:
Any ideas how I can fix this without using plotly, which works?