-2
我想创建闪亮应用,其能够显示交互式情节标题(依赖于x轴已选定值)ř闪亮交互式情节标题ggplot
非常简单的例子:
library(shiny)
library(DT)
library(ggplot2)
x <- as.numeric(1:1000000)
y <- as.numeric(1:1000000)
z <- as.numeric(1:1000000)
data <- data.frame(x,y, z)
shinyApp(
ui = fluidPage(selectInput(inputId = "yaxis",
label = "Y-axis",
choices = list("x","y","z"),
selected = c("x")),
dataTableOutput('tableId'),
plotOutput('plot1')),
server = function(input, output) {
output$tableId = renderDataTable({
datatable(data, options = list(pageLength = 10, lengthMenu=c(10,20,30)))
})
output$plot1 = renderPlot({
filtered_data <- data[input$tableId_rows_all, ]
ggplot(data=filtered_data, aes_string(x="x",y=input$yaxis)) + geom_line()
})
}
)
我曾尝试这样的代码:
ggtitle("Line plot of x vs",input$yaxis)
它不工作,情节还未显示出来,给我一个错误:
Warning: Error in ggtitle: unused argument (input$yaxis)
[重要]
使用ggtitle(input$yaxis)
给了我一个互动的称号,不过,我需要建立一个句子(如:X的支线剧情VSinput$yaxis
),其中反应参数(input$yaxis
)是它的一部分!
感谢您的帮助!
干杯
使用'ggtitle(粘贴(“x线条图”,输入$ yaxis))'? – Axeman