Я работаю над создателем блочной графики для своей группы и хочу включить все наши данные в создатель. Итак, я добавил data.frame
в код, содержащий данные, но я думаю, что поместил его не в то место. Каждый раз, когда я запускаю код на своем конце, он работает отлично, но когда я публикую sh с помощью Shiny и запускаю его на их стороне, я получаю ошибку Warning: Error in eval: object 'Percents' not found
(сообщая мне, что он не может найти данные?) Если кто-то может Помогу, было бы здорово, вот код:
library(shiny)
All_Data <- data.frame(
Name = as.character(c("Jeff","Bob","Greg")),
Year = c(2015,2015,2015),
Bacteria = c("A","B","C"),
Site = c("C1","C1","C1"),
Percents = c(1,2,4),
stringsasfactors = TRUE
)
ndata <-data.frame(
Name = as.character("Preset"),
Year = c("0"),
Bacteria = as.factor(c("0")),
Site = as.factor(c("0")),
Percents = as.numeric(c("0")),
stringsAsFactors = TRUE
)
Names <- c("2015 Acidobacteria C2", "2015 Actinobacteria C2","2015 Alpha-Proteobacteria C2", "2015 Bacteriodetes C2","2015 Verrucomicrobia C2","2016 Acidobacteria C2", "2016 Actinobacteria C2","2016 Alpha-Proteobacteria C2", "2016 Bacteriodetes C2","2016 Verrucomicrobia C2","2018 Acidobacteria C2", "2018 Actinobacteria C2","2018 Alpha-Proteobacteria C2", "2018 Bacteriodetes C2","2018 Verrucomicrobia C2","2019 Acidobacteria C2", "2019 Actinobacteria C2","2019 Alpha-Proteobacteria C2", "2019 Bacteriodetes C2","2019 Verrucomicrobia C2")
Years <- c("2015","2016","2018","2019")
names(Years)<-c("2015 C2","2016 C2","2018 C2","2019 C2")
Sites <- c("","C2")
# Define UI for application
ui <- fluidPage(
# Application title
titlePanel("ISAMR DNA Group Boxplot Maker"),
# Sidebar
sidebarLayout(
sidebarPanel(width = 4,
h3("Which Data Sets Would You Like to Compare?"),
selectInput("Set1", "", choices = c(Sites, Years, Names)),
selectInput("Set2", "",choices = c(Sites, Years, Names)),
selectInput("factor","Based on Which Factor?", choices = c("Year", "Site", "Bacteria", "Site by Year", "Bacteria by Year", "Bacteria by Site by Year")),
textInput("title", h4("Title"), placeholder = "Enter title..."),
numericInput("numcol","How many colors?",value=1,min=1,max=5),
h4("Pick the colors you want, leave the rest blank."),
selectInput("col1","",choices = c("",colors())),
selectInput("col2","",choices = c("",colors())),
selectInput("col3","",choices = c("",colors())),
selectInput("col4","",choices = c("",colors())),
selectInput("col5","",choices = c("",colors())),
actionButton("Submit", "Submit")
),
# Show a chosen plot
mainPanel(
#uiOutput("data"),
DT::dataTableOutput("data"),
plotOutput("plot")
)
)
)
# Define server logic
server <- function(input, output) {
ndata<-eventReactive(input$Submit, {req(input$Submit)
if (input$Set1 %in% Names & input$Set2 %in% Names){
ndata <- filter(All_Data, All_Data$Name == input$Set1 | All_Data$Name == input$Set2)
}
else if (input$Set1 %in% Names & input$Set1 %in% Years){
ndata <- filter(All_Data, All_Data$Name == input$Set1 | All_Data$Year == input$Set2)
}
else if (input$Set1 %in% Names & input$Set1 %in% Sites){
ndata <- filter(All_Data, All_Data$Name == input$Set1 | All_Data$Site == input$Set2)
}
else if (input$Set1 %in% Years & input$Set1 %in% Names){
ndata <- filter(All_Data, All_Data$Site == input$Set1 | All_Data$Name == input$Set2)
}
else if (input$Set1 %in% Years & input$Set2 %in% Years){
ndata <- filter(All_Data, All_Data$Year == input$Set1 | All_Data$Year == input$Set2)
}
else if (input$Set1 %in% Years & input$Set2 %in% Sites){
ndata <- filter(All_Data, All_Data$Year == input$Set1 | All_Data$Site == input$Set2)
}
else if (input$Set1 %in% Sites & input$Set1 %in% Names){
ndata <- filter(All_Data, All_Data$Site == input$Set1 | All_Data$Name == input$Set2)
}
else if (input$Set1 %in% Sites & input$Set1 %in% Years){
ndata <- filter(All_Data, All_Data$Site == input$Set1 | All_Data$Year == input$Set2)
}
else if (input$Set1 %in% Sites & input$Set1 %in% Sites){
ndata <- filter(All_Data, All_Data$Site == input$Set1 | All_Data$Site == input$Set2)
} })
output$data <- DT::renderDataTable({
ndata()
})
observeEvent(input$numcol,{req(input$numcol)
if (input$numcol == 1){coll<-c(input$col1)}
if (input$numcol == 2){coll<-c(input$col1,input$col2)}
if (input$numcol == 3){coll<-c(input$col1,input$col2,input$col13)}
if (input$numcol == 4){coll<-c(input$col1,input$col2,input$col3,input$col4)}
if (input$numcol == 5){coll<-c(input$col1,input$col2,input$col3,input$col4,input$col5)}
})
observeEvent(input$factor,{req(input$factor)
if (input$factor == "Year"){
output$plot <- renderPlot(
boxplot(Percents ~ Year, data = ndata(), main = input$title, ylab = "Relative Abundance", col = coll))
}
else if (input$factor == "Site"){
output$plot <- renderPlot(
boxplot(Percents ~ Site, data = ndata(), main = input$title, ylab = "Relative Abundance", col = coll))
}
else if (input$factor == "Bacteria"){
output$plot <- renderPlot(
boxplot(Percents ~ Bacteria, data = ndata(), main = input$title, ylab = "Relative Abundance", col = coll))
}
else if (input$factor == "Site by Year"){
output$plot <- renderPlot(
boxplot(Percents ~ Year%in%Site, data = ndata(), main = input$title, ylab = "Relative Abundance", col = coll))
}
else if (input$factor == "Bacteria by Year"){
output$plot <- renderPlot(
boxplot(Percents ~ Year%in%Bacteria, data = ndata(), main = input$title, ylab = "Relative Abundance", col = coll))
}
else if (input$factor == "Bacteria by Site by Year"){
output$plot <- renderPlot(
boxplot(Percents ~ Year%in%Site%in%Bacteria, data = ndata(), main = input$title, ylab = "Relative Abundance", col = coll))
}
})
}
# Run the application
shinyApp(ui = ui, server = server)
(я не включил реальные данные)