ich hatte über der Woche nicht ganz soviel Zeit mich weiter mit dem Problem zu beschäftigen. Aber gestern Abend bin ich ein kleines Stückchen weiter gekommen. Hier der der neue Code im Anhang das kleine Date frame.
Code: Alles auswählen
library (shiny)
library(shinyWidgets)
library(viridis)
library(hrbrthemes)
library(rio)
#import
df = import("df.txt"); df
ui <- fluidPage(
titlePanel(title = h4(" Shiny App", align = "center")),
sidebarLayout(
sidebarPanel(
pickerInput(
inputId = "lith",
label = "Wähle Horizont",
choices = unique(df$Horizont), selected = NULL,
multiple = TRUE),
options = list("max-options" = 1,
"max-options-text" = "No more!"),
br(),
#tags$h3("Wähle Element"),
pickerInput(
inputId = "datatable",
label = "Wählen Element",
choices = colnames(df [2:4]),
#choices = rownames(df),
multiple = TRUE,
options = list(`actions-box` = TRUE)
),
textOutput(outputId = "res_classic")),
mainPanel(
tabsetPanel(type = "tab",
tabPanel("Boxplot", plotOutput("box")))
))
)
server <- function(input, output, session) {
# The boxplot
output$box = renderPlot({
ggplot(df, aes(x=input$lith, y=.data[[input$datatable]])) +
geom_boxplot(notch = TRUE, color = "#e9ecef", fill="#69b3a2", outlier.colour = "red", width = 0.6)+
stat_summary(fun = "mean", color = "black", shape = 8) +
geom_jitter(alpha = 0.8, width = 0.2, height = 0, color = "orange") +
#facet_wrap( ~ Horizont, scales = 'free_y', nrow = 1)+
#coord_flip()+
#ggtitle("Boxplot") +
labs(title = "Boxplot",
subtitle = "Black stars: mean value
Red dots: outlier",
caption = "",
tag = "")+
theme_ipsum() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank())+
theme(plot.title = element_text(size=15))
}, res = 96, height = 600, width = 900 )
}
shinyApp(ui, server)
Code: Alles auswählen
choices = unique(df$Horizont, selected = Null)
Die zweite Ergänzung ist in ggplot.
Code: Alles auswählen
ggplot(df, aes(x=input$lith, y=.data[[input$datatable]]))
Meine Frage lautet. Wie kann ich den korrekten Plot bekommen? Oder andersrum - wie bekomme ich in der Grafik nun tatsächlich nur die Werte für den jeweiligen Horizont angezeigt? Nächste Frage ist es möglich ein zweites Element neben dem ersten aus demselben Horizont dazu zu stellen?
Ich bin jedem Tipp und jeder Hilfe sehr dankbar!
Viele Grüße,
retep