Thanks for the reply. I've re-installed RStudio, but still no luck. Running it in regular R works (locally), but the server deploy has the same issue that RStudio reports as if I had clicked the 'Run App' button. It appears if I run the code and then click the 'Run App' button, it works (locally), but won't deploy to shinyapp. If I clean my environment, it won't run again (locally).
Since the demo code I posted above wasn't working, I took the code directly from the tutorial site and it still doesn't work. This must be some environment issue? Any suggestions to get around it? I'm about ready to forfeit shiny if the same code on two machines works differently.
# Library prep
library(shiny)
library(survival)
library(survminer)
library(dplyr)
library(ggplot2)
# Code taken from https://www.datacamp.com/community/tutorials/survival-analysis-R
data(ovarian)
ovarian$rx <- factor(ovarian$rx,
levels = c("1", "2"),
labels = c("A", "B"))
ovarian$resid.ds <- factor(ovarian$resid.ds,
levels = c("1", "2"),
labels = c("no", "yes"))
ovarian$ecog.ps <- factor(ovarian$ecog.ps,
levels = c("1", "2"),
labels = c("good", "bad"))
ovarian <- ovarian %>% mutate(age_group = ifelse(age >=50, "old", "young"))
ovarian$age_group <- factor(ovarian$age_group)
surv_object <- Surv(time = ovarian$futime, event = ovarian$fustat)
fit1 <- survfit(surv_object ~ rx, data = ovarian)
test <- ggsurvplot(fit1, data = ovarian, pval = TRUE)
# shiny time
ui <- fluidPage(
plotOutput("s")
)
server <- function(input, output, session) {
output$s <- renderPlot({test})
}
shinyApp(ui, server)