我希望在闪亮的仪表板中有不同的页面.首先,我创建了一个登录页面,为用户和管理员提供身份验证.之后,如果管理员登录系统想要查看用户无法访问它们的一些选项.问题:当我以用户或管理员身份登录时,我可以在后台看到主要的ui.r页面如何解决此问题,只能看到admin.R或user.R?当用户登录仪表板时显示,当管理员登录时,仪表板和小部件显示.所以我决定在R中创建4个页面如下:ui.R
library(shiny)
library(shinydashboard)
shinyUI(
dashboardPage(
dashboardHeader(title = "Navigational Support System"),
dashboardSidebar(),
dashboardBody(
box(
uiOutput("page")
)
)
)
)
Run Code Online (Sandbox Code Playgroud)
server.R
library(shiny)
library(shinydashboard)
source("user.R")
source("admin.R")
############################################################################################################
#Login USER and ADMIN TO the System
my_username <- c("test","admin")
my_password <- c("test","123")
get_role=function(user){
if(user=="test") {
return("TEST")
}else{
return("ADMIN")
}
}
get_ui=function(role){
if(role=="TEST"){
return(list_field_user)
}else{
return(list_field_admin)
}
}
shinyServer(function(input, output,session) {
USER <- reactiveValues(Logged = FALSE,role=NULL)
ui1 <- function(){
tagList(
div(id = "login",
wellPanel(textInput("userName", "Username"),
passwordInput("passwd", "Password"),
br(),actionButton("Login", "Log in")))
#tags$style(type="text/css", '#login{ width:750px; float:left;}')
)}
ui2 …Run Code Online (Sandbox Code Playgroud) 在我正在开发的系统中,我有3个不同的演员(用户,管理员,支持团队)使用Shiny App.我想知道如何为这三个演员提供身份验证,每个演员只能访问他们的页面.我发现可以使用闪亮的服务器Pro,它不是免费的.有没有办法做到这一点,而不是使用闪亮的服务器专业版.在UI.R中,代码如下:
library(shiny)
library(shinydashboard)
rm(list = ls())
Logged = FALSE;
my_username <- "test"
my_password <- "test"
ui1 <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
box(
ui = (htmlOutput("page"))
)
)
)
Run Code Online (Sandbox Code Playgroud)
在Server.R中,代码如下:library(shinydashboard)
库(闪亮)
server = (function(input, output,session) {
ui1 <- function(){
tagList(
div(id = "login",
wellPanel(textInput("userName", "Username"),
passwordInput("passwd", "Password"),
br(),actionButton("Login", "Log in"))),
tags$style(type="text/css", "#login {font-size:10px; text-align: left;position:absolute;top: 40%;left: 50%;margin-top: -100px;margin-left: -150px;}")
)}
ui2 <- function(){tagList(tabPanel("Test"))}
USER <<- reactiveValues(Logged = Logged)
observe({
if (USER$Logged == FALSE) {
if (!is.null(input$Login)) {
if (input$Login > …Run Code Online (Sandbox Code Playgroud) 我使用R在图表中绘制了两个点,并用箭头连接点.如何在箭头上添加文本.(固定文本)我的代码如下:
x<-y<-1
new.x<-2
new.y<-2
Text<-"Direction"
plot(x, y, xaxt='n',yaxt='n',cex=10,pch=19,xlim=c(0,4), ylim=c(0,3))
points(new.x,new.y,cex=10,pch=19)
arrows(x, y, new.x, new.y, col = "orange",lwd=4,lty=4)
Run Code Online (Sandbox Code Playgroud)
在箭头上我想在箭头上添加一个Text对象("Direction").
图像如下: