ui.Rからのドロップダウンの選択に基づいてデータをプロットするために、サーバーに不具合があります。私は 'サイト'と 'パラメータ'を選択し、 'サイト'と 'パラメータ'を反映した 'Obs'をプロットしたいと思います。 ObsをYとDateとしてXにします。ここにいくつかのサンプルコードを示します。同じデータセット内の光沢のある反応プロットの複数の条件
Site_Names=data.frame(c(A=rep("A",10),B=rep("B",10),C=rep("C",10)))
Site_Names=Site_Names[,1]
Parameters=data.frame(c(pH=rep("pH",10),DO=rep("DO",10),Temp=rep("Temp",10)))
Parameters=Parameters[,1]
Obs=rnorm(30)
Dates=c(seq(as.Date("2000/1/1"), by = "year", length.out =10),
seq(as.Date("2005/1/1"), by = "year", length.out =10),
seq(as.Date("1990/1/1"), by = "year", length.out =10))
data=data.frame(Site_Names,Parameters,Obs,Dates)
#ui.R
Sites=levels(data$Site_Name)
setNames(as.list(Sites), Sites)
params=levels(data$Parameters)
setNames(as.list(params), params)
library(shiny)
library(ggplot2)
shinyUI(fluidPage(
# Application title
titlePanel("Data"),
sidebarLayout(
sidebarPanel(
selectInput("site", "Select Site:", Sites),
selectInput("parameters", "parameter", params)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("Plot")
)
)
))
#server.R
library(shiny)
library(ggplot2)
shinyServer(function(input, output) {
dataset <- reactive({
data[ , (input$Sites),]
})
output$distPlot <- renderPlot({
p <- ggplot(dataset(), aes(x=Dates, y=input$params and input$Sites))
+ geom_point(data$Obs)
print(p)
})
あなたはプロットをどのように見せたいか考えてください。 –
x軸上の日付とy軸上の 'Obs'データを持つ基本的な散布図または線図。理想的には、サイトとパラメータに基づいて日付が変更される – shum