library(shiny) library(tidyverse) hinnad=read_csv("https://minitorn.tlu.ee/~jaagup/kool/java/kursused/21/andmeanalyysi_lahendused_r_keeles/naited/0930/apple.csv") %>% na.omit() ui <- fluidPage( titlePanel("Apple aktsiad"), sliderInput("loppaeg", "kuni", min=as.Date("1980-01-01"), max=as.Date("2020-01-01"), value=c(as.Date("2003-01-01"), as.Date("2005-01-01"))), plotOutput("joonis1") ) #Paigutage telgedele 2 arvulist väärtust (nt. Open ja Close) #Paigutage ekraanile püstjoon nähtavate andmete #avamishinna aritmeetilise keskmisega #Lisage joonena avamishinna mediaan ning sulgemishinna keskmine ja mediaan #Aadress veebis: https://jaagupkippar.shinyapps.io/Apple2/ server <- function(input, output) { output$joonis1 <- renderPlot({ print(input$loppaeg[[2]]) d1 <- hinnad %>% filter(Date > input$loppaeg[[1]], Date < input$loppaeg[[2]]) d1 %>% ggplot(aes(Open, Close, label=substr(as.character(Date), 4, 4)))+geom_text()+ ylim(0, max(d1$Open)) + geom_vline(xintercept = mean(d1$Open)) + geom_vline(xintercept = median(d1$Open), color="blue") }) } shinyApp(ui = ui, server = server)