I am making my first attempts with shiny package, it's awesome. But, as usual, I am facing some problems. I've managed, following shiny tutorial and googleing, to show two different plots of different meteo stations but both showing the same variable.

I wanted to add another input list so it is possible to choose which var is to be plotted. When trying to run the script it seems to run without any errors but no plot appear, just the select menues.

Maybe there is a mistake in passing the variables to server.R so the output oblject plots are not properly build, just a guess. Tried to work in a general way creating functions depending on input vars but I am missing something, maybe about reactivity, maybe correctly passing vars,...
These are the codes for 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")
)
)
))
and 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)
})
})
Thank you in advance for your help and advice
plot=p(input$var)is wrongaes_string(), than you for posting this answer.