http://rstudio.github.io/shiny-server/latest/#flat-file-authentication. See section 4.1 which shows this code:
shinyServer(function(input, output, session) {
output$username <- reactive({
session$user
})That code works if you want to use session$user in output BUT I need to access session$user in the ui.r file via the GetUser() function in my ui
Here is my ui.r File:
library(shiny)
shinyUI(fluidPage(
textOutput("HeaderTime"),
sidebarPanel(
selectInput("t", "t:", as.character(GetUser()), selected = as.character(GetUser())), width = 2
),
mainPanel(
tabsetPanel(
tabPanel("test",
dataTableOutput("Table"),
plotOutput("Plot"),
# verbatimTextOutput("Txt"),
width = 12
)
)
)
))
You can see the GetUser() function in the selectInput. I have placed GetUser() in my server.R file here and made it reactive thinking this would work but it does not.
shinyServer(function(input, output, session) {
GetUser<-reactive({
return(session$user)
})
output$Plot<-renderPlot({
hist(rnorm(1000))
})
output$Table<- renderDataTable({
data.frame(a=c(1,2,3,4),b = c("TEst","test","test","test"))
})
})when I run this code I get the error:
Error in GetUser() : argument "session" is missing, with no defaultAny idea how to allow the ui.r to access GetUser() in the server.r file so session$user can be used in the ui?
Here is code to run project:
library(rJava)
library(shiny)
install.packages("shiny")
runApp("C://me/pathtoproject")
--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/3027b0c3-e878-4928-a244-a97a63e3bd42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.