Dear All,

I was wondering if someone could please help me? I am new to working in Shiny apps using Rstudio. I am facing an issue with the coding, I am printing a ggplot by uploading a CSV file which works fine. Issue I am facing is to print values of certain variables which show the parameters being passed to GGPLOT. I want to achieve following

- Printing the value of variables to browser underneath the plot or above plot
- Write a CSV file containing these variables and download it.

Hope I have explained my question correctly. I am copying sample code underneath

///////////////////////////////////////////////////////////////////////////////////////////////////////////

# Global variables can go here

options(scipen=999)

library(survival)

# # Define the UI

ui <- bootstrapPage(

titlePanel("Survival analysis step1"),

tags$hr(),

sidebarPanel(

fileInput("file1", "Choose CSV File",

multiple = FALSE,

accept = c("text/csv",

"text/comma-separated-values,text/plain",

".csv")),

```
# Horizontal line ----
tags$hr(),
# Input: Checkbox if file has header ----
checkboxInput("header", "Header", TRUE),
# Input: Select separator ----
radioButtons("sep", "Separator",
choices = c(Comma = ",",
Semicolon = ";",
Tab = "\t"),
selected = ","),
# Input: Select quotes ----
radioButtons("quote", "Quote",
choices = c(None = "",
"Double Quote" = '"',
"Single Quote" = "'"),
selected = '"'),
# Horizontal line ----
tags$hr(),
# Input: Select number of rows to display ----
radioButtons("disp", "Display",
choices = c(Head = "head",
All = "all"),
selected = "head")
```

),

mainPanel(

plotOutput('plot')

)

)

# Define the server code

server <- function(input, output) {

output$plot <- renderPlot({

```
req(input$file1)
# when reading semicolon separated files,
# having a comma separator causes `read.csv` to error
testdf <- read.csv(input$file1$datapath,
header = input$header,
sep = input$sep,
quote = input$quote)
```

#testdf<-read.csv("objective.csv",header = TRUE,na.strings=0)

testdf[is.na(testdf)]<-"0"

testdf$objl<-ifelse(as.numeric(testdf$obj_censor) ==2, as.numeric(testdf$objn), as.numeric(testdf$objl))

testdf$modified_objn<-ifelse(as.numeric(testdf$obj_censor) ==2, as.numeric(testdf$objl), as.numeric(testdf$objn))

set.seed(1234567)

testdf$Survial_analysis_obj<-Surv(as.numeric(testdf$modified_objn),as.numeric(testdf$objl), as.numeric(testdf$obj_censor), type="interval")

model_log_N_obj<-survreg(formula= testdf$Survial_analysis_obj~1, data=testdf, dist="lognormal")

new1<-data.frame(1)

predmodel_log_N_obj<-predict(model_log_N_obj, newdata=new1, type='quantile', p=seq(0.001,0.99, by=0.0001), se.fit=TRUE)

```
plot(predmodel_log_N_obj$fit, seq(0.001,0.99, by=0.0001),
type="l", col=2, lty=1, lwd=2, xlim=c(0.00001,100000000),
main="Log-normal probability distribution models (objective symptoms)",
xlab="dose of peanut protein (mg)",
ylab = "probability",
log="x", xaxt = "n", yaxt = "n")
lines(exp(log(predmodel_log_N_obj$fit)+1.96* (predmodel_log_N_obj$se.fit)/ predmodel_log_N_obj$fit),seq(0.001,0.99, by=0.0001), type="l", col=2, lty=2)
lines(exp(log(predmodel_log_N_obj$fit)-1.96* (predmodel_log_N_obj$se.fit)/ predmodel_log_N_obj$fit),seq(0.001,0.99, by=0.0001), type="l", col=2, lty=2)
log_N_obj1<-predict(model_log_N_obj, newdata=new1, type='quantile', p=0.01, se.fit=TRUE) #0.18
#lower confidence level - 0.04
log_N_CL_obj1 <- exp(log(log_N_obj1$fit)-1.96* (log_N_obj1$se.fit)/ log_N_obj1$fit)
#upper confidence level - 0.75
log_N_CU_obj1<- exp(log(log_N_obj1$fit)+1.96* (log_N_obj1$se.fit)/ log_N_obj1$fit)
```

########### Trying to print and save these variables and write data frame into csv file

df<-data.frame(log_N_CU_obj1)

df$log_N_CL_obj1<-log_N_CL_obj1

df$log_N_obj1fit<-log_N_obj1$fit

})

visFun <- renderPrint(env=parent.frame(),{

log_N_obj1

}

)

visFun()

}

# Return a Shiny app object

shinyApp(ui = ui, server = server)

///////////////////////////////////////////////////////////////////////////////////////////////////////////