我正在使用plotly包R来显示我的shiny应用程序中的一些大图,图表显示良好的预期.但是,当我单击"下载为png"按钮时,已下载的.png已调整大小.这是这种行为的演示.
如何指定导出图的分辨率?
这是一个最小的例子,通过在下载时剪切一个非常长的标题来证明这个问题
app.R
library(shiny)
library(ggplot2)
library(plotly)
ui <- fluidPage(titlePanel("Plotly Download demo"),
plotlyOutput("demoPlotly"))
server <- function(input, output) {
output$demoPlotly <- renderPlotly({
#make an arbritrary graph with a long title
p <- iris %>%
ggplot(aes(x = Petal.Length, y = Petal.Width, color = Species)) +
geom_point() +
labs(title = "This is a really long title to demo my problem of plotly resizing my downloaded output")
ggplotly(p)
})
}
# Run the application
shinyApp(ui = …Run Code Online (Sandbox Code Playgroud) 在制作更大的应用程序时,RShiny我喜欢将我的代码保存在单独的文件中以用于单独的选项卡或菜单。当我RShiny在.R文件中放置命令并使用source()命令调用它时,TRUE会在 UI 元素下方打印a 。我试图调用源都ui.R使用uiOutput()以及invisible()。
如何停止TRUE渲染?
例子:
应用程序
library(shiny)
ui <- fluidPage(h4("Attempt 1"),
source("TestSource.R",local=T),
h4("Attempt 2"),
uiOutput("at2"),
h4("Attempt 3"),
invisible(source("TestSource.R")))
server <- function(input, output) {
output$at2 <- renderUI({
invisible(source(
"TestSource.R",
verbose = F,
echo = F,
print.eval = F,
prompt.echo = F,
local = T
))
})
}
shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)
测试源文件
helpText("This is a test")
Run Code Online (Sandbox Code Playgroud)
这是呈现的内容
提前致谢。
我有一个应用程序,它有很多输入,并且使用actionButton()进行一些计算,这需要花费大量时间,包括读取一些文件和绘制地图。
在一些用户测试过程中,一些反馈称调整输入后需要重新按下actionButton()键并不直观。我想呈现一条警告消息(阅读“有用的提醒”),用户需要重新按actionButton(). 如果此消息仅在上次按 后输入发生更改后才呈现,我希望如此actionButton()。
到目前为止,我已经尝试在“eventReactive()”中使用全局变量,但identical() 没有成功。
我的问题是:actionButton()当自上次按下按钮以来任何输入发生更改时,如何呈现有用的提醒以重新按下?
这是一个具有许多输入的应用程序的最小示例,需要一些时间才能输出某些内容
## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
#arbritray inputs
sliderInput("in1", label = "Input 1", value=1,min=0,max=5),
sliderInput("in2", label = "Input 2", value=2,min=0,max=5),
sliderInput("in3", label = "Input 3", value=3,min=0,max=5),
actionButton("StartCalculation","Calculate")
),
dashboardBody(
textOutput("answer")
)
)
server <- function(input, output) {
out <- eventReactive(input$StartCalculation,{
Sys.sleep(2) #simulate long computation
input$in1+input$in2+input$in3
})
output$answer <- renderText({
out()
})
}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)