我正在尝试将我的Shiny应用程序重定向到另一个页面.我正在使用httr发送GET请求并查看用户是否已登录.如果不是,我想将其重定向到另一个链接.
我可以只使用R/Shiny做到这一点,还是需要一些额外的库?
样品:
library(httr)
library(shiny)
shinyServer(function(input, output) {
rv <- reactiveValues()
rv$mytoken = session$request$token
observeEvent(input$button1, {
rv$a <- GET("my.url:3405/authtoken",
add_headers(
.headers = c("token" = rv$mytoken)
))
if (rv$a$status_code == 200) {
} else {
# redirect magic
}
})
}
shinyUI(fluidPage(
actionButton(button1, "btn")
))
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Plotly和用一些异常值来可视化数据Python3。异常值导致色标图例看起来很糟糕:只有很少的高数据点,但图例看起来很糟糕:2k 和 10k 之间的空间太大。
所以问题是,如何更改右侧“颜色图例”的外观(见下图),以便它主要显示 0 到 2k 之间的差异?不幸的是,无法从这个文档文件中得到答案
示例代码(jupyter notebook):
import numpy as np
from plotly.offline import download_plotlyjs, init_notebook_mode, iplot
from plotly.graph_objs import *
init_notebook_mode()
x = np.random.randn(100,1) + 3
y = np.random.randn(100,1) + 10
x = np.reshape(x, 100)
y = np.reshape(y, 100)
color = np.random.randint(0,1000, [100])
color[[1,3,5]] = color[[1,3,5]] + 10000 # create outliers in color var
trace = Scatter(
x = x,
y = y,
mode = 'markers',
marker=dict(
color = …Run Code Online (Sandbox Code Playgroud) 这是代码片段,问题是:如何observeEvent()在 a 中reactive()更改a值?
编辑:真正的问题是,“没有reactiveValues()吗?
ui <- fluidPage(
actionButton("btn_change", "Change Values"),
actionButton("btn_print","Print values")
)
server <- function(input, output) {
a <- 1
data <- reactive({
observeEvent(input$btn_change, {
a <- a + 1
})
a
})
observeEvent(input$btn_print, {
print(paste("data = ", data()))
})
}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud) 有没有一种方法可以将弹出框或工具提示添加到
output$Text <- renderText({ c("TestText") })元素,然后renderUI使用ShinyBS 通过呈现?