私は輝くパッケージで初めての試みをしています。しかし、いつものように、私はいくつかの問題に直面しています。私は光沢のあるチュートリアルとgoogleingの後、異なるmeteoステーションの2つの異なるプロットを表示するように管理しましたが、両方とも同じ変数を示しています。選択リストから反応プロットへの光沢のあるパス変数
私はプロットされるべきVAR選択することが可能であるので、別の入力リストを追加したいです。スクリプトを実行しようとすると、エラーなしで実行されるように見えますが、プロットは表示されません。
おそらく、変数obliterをserver.Rに渡す際に間違いがあり、出力oblotプロットが適切に構築されていないと推測されます。入力VARSに応じたが、私は多分反応性について何か、多分正しく渡すVARSをしないのです関数を作成する一般的な方法で動作するようにしようとしました、...
これらはui.R
library("shiny")
shinyUI(pageWithSidebar(
headerPanel('Comparación de zonas - Temperatura'),
sidebarPanel(
selectInput("panel1", "Zona:",
list("Zona 1" = "1",
"Zona 2" = "2",
"Zona 3" = "3",
"Zona 4" = "4")),
selectInput("panel2", "Zona:",
list("Zona 1" = "1",
"Zona 2" = "2",
"Zona 3" = "3",
"Zona 4" = "4")),
selectInput("var", "Variable:",
list("tempc" = "tempc",
"relhum" = "relhum")),
helpText('Al seleccionar la zona se crearán automáticamente
el gráfico de evolución temporal.')
),
mainPanel(
conditionalPanel(condition = "inputId == 'panel1'",plotOutput('myplot')
),
conditionalPanel(condition = "inputId == 'panel2'",plotOutput("myplot")
)
)
))
用のコードですそしてserver.R
library(shiny)
library(plyr)
library(ggplot2)
shinyServer(function(input, output) {
formulaText <- reactive(function() {
paste("Gràfica de ggplot: Zona ", input$zona1)
})
# Return the formula text for printing as a caption
output$caption <- reactiveText(function() {
formulaText()
})
# datasets
datos=read.table("data.dat",header=T)
data=as.data.frame(datos)
data=within(data, datetime <- as.POSIXct(paste(date, time),format = "%Y%m%d %H%M%S"))
rams <- reactive({
subset(data,data$stat_id %in% places$stat_id[places$Zona == input$panel1])
})
plot <- function(var) {
p <- ggplot(rams(),aes(x=datetime, y=var, colour=as.character(stat_id))) +
geom_line()
}
plot=p(input$var)
if(input$var == "tempc") {
plot <- plot + ylab("Temperatura (ºC)") + xlab(" ") +
ggtitle(gtitol) + theme(legend.title=element_blank()) + theme(legend.position="bottom") +
scale_y_continuous(limits = c(-20,ylim),breaks=c(seq(-20,ylim,by=2))) }
if (input$var == "relhum") {
plot <- plot +
ylab("Humedad relativa (%)") + xlab(" ") +
ggtitle(gtitol) + theme(legend.title=element_blank()) + theme(legend.position="bottom") +
scale_y_continuous(limits = c(0,100),breaks=c(seq(0,100,by=5))) }
output$myplot <- reactivePlot(function() {
print(plot)
})
})
は、最後に私が成功してきたあなたの助けやアドバイス
'プロット= P(入力$ var) 'が間違っている –
はい、これは唯一の問題ではありませんでした。下の私の答えを見てください。ありがとう。 – pacomet
'aes_string()'をよく知っておいて、この回答を投稿してください。 –