0byt3m1n1
Path:
C:
/
Users
/
Administrator
/
AppData
/
Local
/
RStudio
/
[
Home
]
File: history_database
1678353542799:load("C:/Users/Administrator/Desktop/New folder/R/R.txt") 1678353877360:setwd("C:/GEOMATICS 23-01-2021/RServer") 1678357345945:library(shiny); runApp('Re.R') 1678357366528:library(anytime) 1678357368007:library(askpass) 1678357369621:library(BH) 1678357371037:library(bit) 1678357373317:library(bit64) 1678357374805:library(boot) 1678357375772:library(bslib) 1678357376669:library(cachem) 1678357379829:library(class) 1678357380724:library(cli) 1678357382605:library(clipr) 1678357383210:library(cluster) 1678357388157:library(codetools) 1678357388748:library(colorspace) 1678357389451:library(commonmark) 1678357390105:library(compiler) 1678357390899:library(cpp11) 1678357392084:library(crayon) 1678357392835:library(crosstalk) 1678357401620:library(zoo) 1678357402220:library(yaml) 1678357402900:library(xtable) 1678357403900:library(xml2) 1678357404539:library(xfun) 1678357405916:library(withr) 1678357406548:library(vroom) 1678357407132:library(visNetwork) 1678357408276:library(viridisLite) 1678357408853:library(viridis) 1678357409412:library(vctrs) 1678357411941:library(utf8) 1678357414675:library(tzdb) 1678357415245:library(translations) 1678357415725:library(tools) 1678357503006:install.packages("shiny") 1678357574808:install.packages(c("library(shiny)", "library(dplyr)", "library(ggplot2)", "library(plotly)", "library(tidyr)", "library(zoo)", "library(lubridate)", "library(RColorBrewer)", "library(shinythemes)", "library(shinyWidgets)", "library(DiagrammeR)", "library(ggtext)")) 1678357639673:runApp('Re.R') 1678357816109:setwd("C:/GEOMATICS 23-01-2021/RServer/R") 1678358915688:setwd("C:/GEOMATICS 23-01-2021/RServer/R") 1678358973324:install.packages("shiny") 1678359152087:options(repos=c(cran="http://cran.rstudio.com")) 1678359175637:install.packages("shiny") 1678360621421:install.packages("shiny") 1678360703058:install.packages("dplyr") 1678360742222:install.packages("ggplot2") 1678360768821:install.packages("plotly") 1678360790851:install.packages("tidyr") 1678360807111:install.packages("zoo") 1678360825014:install.packages("lubridate") 1678360842401:install.packages("RColorBrewer") 1678360857551:install.packages("shinythemes") 1678360872878:install.packages("shinyWidgets") 1678360894269:install.packages("DiagrammeR") 1678360909797:install.packages("ggtext") 1678360927289:library(shiny) 1678360928347:library(dplyr) 1678360929223:library(ggplot2) 1678360929517:library(plotly) 1678360930304:library(tidyr) 1678360930325:library(zoo) 1678360930445:library(lubridate) 1678360930917:library(RColorBrewer) 1678360930943:library(shinythemes) 1678360930977:library(shinyWidgets) 1678360931166:library(DiagrammeR) 1678360931243:library(ggtext) 1678360931344:# Read the daily rainfall data 1678360931345:rainfall_data <- read.csv("rainfall_data.csv") 1678360983926:load("C:/GEOMATICS 23-01-2021/RServer/R/rainfall_data.csv") 1678360989815:library(shiny) 1678360989817:library(dplyr) 1678360989818:library(ggplot2) 1678360989820:library(plotly) 1678360989821:library(tidyr) 1678360989822:library(zoo) 1678360989824:library(lubridate) 1678360989825:library(RColorBrewer) 1678360989826:library(shinythemes) 1678360989828:library(shinyWidgets) 1678360989829:library(DiagrammeR) 1678360989831:library(ggtext) 1678360989832:# Read the daily rainfall data 1678360989833:rainfall_data <- read.csv("rainfall_data.csv") 1678361066422:setwd("C:/GEOMATICS 23-01-2021/RServer/PVR") 1678361076078:library(shiny) 1678361076080:library(dplyr) 1678361076082:library(ggplot2) 1678361076083:library(plotly) 1678361076085:library(tidyr) 1678361076086:library(zoo) 1678361076087:library(lubridate) 1678361076089:library(RColorBrewer) 1678361076090:library(shinythemes) 1678361076091:library(shinyWidgets) 1678361076093:library(DiagrammeR) 1678361076094:library(ggtext) 1678361076095:# Read the daily rainfall data 1678361076096:rainfall_data <- read.csv("rainfall_data.csv") 1678361204218:runApp('test.R') 1678361447692:rainfall_data <- read.csv("C:/GEOMATICS 23-01-2021/RServer/R/rainfall_data.csv", sep="") 1678361447707:View(rainfall_data) 1678361459227:runApp('test.R') 1678361545384:runApp('test.R') 1678361613914:setwd("C:/GEOMATICS 23-01-2021/RServer/R") 1678361617437:runApp('C:/GEOMATICS 23-01-2021/RServer/PVR/test.R') 1678361622712:runApp('C:/GEOMATICS 23-01-2021/RServer/PVR/test.R') 1678361652591:setwd("C:/GEOMATICS 23-01-2021/RServer") 1678361654916:runApp('PVR/test.R') 1678361660667:runApp('PVR/test.R') 1678361662675:runApp('PVR/test.R') 1678361716297:setwd("C:/GEOMATICS 23-01-2021/RServer/R") 1678361744451:setwd("C:/GEOMATICS 23-01-2021/RServer") 1678361817955:R <- read.table("C:/GEOMATICS 23-01-2021/RServer/R/R.txt", header=TRUE, quote="\"") 1678361817960:View(R) 1678361896299:runApp('PVR/test.R') 1678361914068:setwd("C:/GEOMATICS 23-01-2021/RServer") 1678361915942:runApp('PVR/test.R') 1678361956988:View(R) 1678361964891:View(R) 1678361975539:View(rainfall_data) 1678361999451:runApp('~/Re.R') 1678362028853:runApp('~/Re.R') 1678362172134:View(rainfall_data) 1678362220811:setwd("C:/GEOMATICS 23-01-2021/RServer") 1678362239835:View(rainfall_data) 1678424271647:install.packages(c("shiny", "dplyr", "ggplot2", "plotly", "tidyr", "zoo", "lubridate", "RColorBrewer", "shinythemes", "shinyWidgets", "DiagrammeR", "ggtext")) 1678424364701:rainfall_data <- read.csv("C:/GEOMATICS 23-01-2021/RServer/R/rainfall_data.csv", sep="") 1678424364716:View(rainfall_data) 1678424373139:library(shinythemes) 1678424378558:library(shiny) 1678424378634:library(dplyr) 1678424379432:library(ggplot2) 1678424379700:library(plotly) 1678424380465:library(tidyr) 1678424380484:library(zoo) 1678424380597:library(lubridate) 1678424381087:library(RColorBrewer) 1678424381111:library(shinythemes) 1678424381112:library(shinyWidgets) 1678424381275:library(DiagrammeR) 1678424381335:library(ggtext) 1678424381432:# Read the daily rainfall data 1678424381435:rainfall_data <- read.csv("rainfall_data.csv") 1678424428174:setwd("C:/GEOMATICS 23-01-2021/RServer") 1678424432616:library(shiny) 1678424432618:library(dplyr) 1678424432620:library(ggplot2) 1678424432621:library(plotly) 1678424432622:library(tidyr) 1678424432624:library(zoo) 1678424432625:library(lubridate) 1678424432626:library(RColorBrewer) 1678424432628:library(shinythemes) 1678424432629:library(shinyWidgets) 1678424432630:library(DiagrammeR) 1678424432632:library(ggtext) 1678424432633:# Read the daily rainfall data 1678424432634:rainfall_data <- read.csv("rainfall_data.csv") 1678424587495:setwd("C:/GEOMATICS 23-01-2021/RServer/R") 1678424594028:library(shiny) 1678424594030:library(dplyr) 1678424594031:library(ggplot2) 1678424594032:library(plotly) 1678424594034:library(tidyr) 1678424594035:library(zoo) 1678424594037:library(lubridate) 1678424594038:library(RColorBrewer) 1678424594040:library(shinythemes) 1678424594041:library(shinyWidgets) 1678424594042:library(DiagrammeR) 1678424594044:library(ggtext) 1678424594045:# Read the daily rainfall data 1678424594046:rainfall_data <- read.csv("rainfall_data.csv") 1678424594060:# Clean and pre-process the data 1678424594061:start_date <- as.Date("1987-01-01") 1678424594065:end_date <- as.Date("2023-02-28") 1678424594066:Date <- seq(from = start_date, to = end_date, by = "day") 1678424594070:rainfall_data$Date <- Date 1678424594071:rainfall_data$Date <- as.Date(rainfall_data$Date, format = "%Y-%m-%d") 1678424594072:rainfall_data$Week <- week(rainfall_data$Date) 1678424594077:rainfall_data$Month <- month(rainfall_data$Date) 1678424594089:rainfall_data$Year <- year(rainfall_data$Date) 1678424594096:# Group the data by Year and Month, and calculate the average rainfall for each group 1678424594103:rainfall_data <- rainfall_data %>% 1678424594117:group_by(Year, Month) %>% 1678424594118:mutate(avg_rainfall = mean(rainfall)) 1678424594190:# Remove missing values from the dataframe 1678424594192:rainfall_data <- na.omit(rainfall_data) 1678424594209:# Ungroup the data 1678424594210:rainfall_data <- ungroup(rainfall_data) 1678424594211:# Create a new variable indicating the season information 1678424594212:rainfall_data <- rainfall_data %>% 1678424594213:mutate(Season = ifelse(Month %in% c(12, 1, 2), "Winter", 1678424594214:ifelse(Month %in% c(3, 4, 5), "Summer", 1678424594215:ifelse(Month %in% c(6, 7, 8, 9), "South West Monsoon", "Post Monsoon")))) 1678424594260:## 1678424594261:# Define UI 1678424594262:ui <- navbarPage( 1678424594264:title = HTML("<span style='font-size: 36px; color: #FFFFFF; font-family: Arial, sans-serif; font-weight: bold; text-shadow: 1px 1px #000000;'>Discover the Secrets of Rainfall: An Interactive Data Visualization Tool</span>"), 1678424594265:theme = shinytheme("paper"), 1678424594266:tags$head( 1678424594267:tags$style( 1678424594268:HTML(" 1678424594269:body { 1678424594270:background-image: url('https://cdn.pixabay.com/photo/2016/06/08/12/08/sea-1440809_960_720.jpg'); 1678424594271:background-repeat: no-repeat; 1678424594272:background-size: cover; 1678424594273:background-position: center center; 1678424594274:} 1678424594275:.navbar-default { 1678424594276:background-color: #1f2d3d; 1678424594281:border-color: #1f2d3d; 1678424594282:} 1678424594283:.navbar-default .navbar-brand { 1678424594284:color: #FFFFFF; 1678424594285:} 1678424594286:") 1678424594287:) 1678424594288:), 1678424594289:tabPanel(tags$h3("Home", style = "color: #fff; background-color: #007bff; padding: 10px; "), 1678424594290:fluidPage( 1678424594291:titlePanel("Welcome to Our Rainfall Insights Dashboard !"), 1678424594296:mainPanel( 1678424594296:tags$style(type="text/css", " 1678424594297:h2 {color: #007bff; font-weight: bold; text-align: center; margin-top: 40px; margin-bottom: 40px;} 1678424594299:h3 {color: #007bff; font-weight: bold;} 1678424594300:p {font-size: 16px; color: #444444;} 1678424594301:.about-panel {background-color: #f8f9fa; padding: 20px; border-radius: 10px; box-shadow: 0px 0px 15px #888888;} 1678424594303:.header-logo {padding: 20px 0; text-align:center;} 1678424594304:"), 1678424594305:div(class = "about-panel", 1678424594306:div( 1678424594308:class = "header-logo", 1678424594309:style = "filter: brightness(110%) contrast(80%) saturate(120%) hue-rotate(20deg);", 1678424594310:img( 1678424594311:src = "http://www.cwrdm.org/nexshop/themes/cwrdm/assets/img/cwrdm_header_iso.png", 1678424594312:alt = "CWRDM Logo", 1678424594313:height = "150px" 1678424594314:) 1678424594315:), 1678424594316:tags$style( 1678424594317:HTML(" 1678424594318:.number-circle { 1678424594319:display: inline-block; 1678424594320:text-align: center; 1678424594322:vertical-align: middle; 1678424594323:width: 30px; 1678424594324:height: 30px; 1678424594325:border-radius: 50%; 1678424594326:background-color: #007bff; 1678424594328:color: white; 1678424594329:font-weight: bold; 1678424594330:font-size: 16px; 1678424594331:margin-right: 10px; 1678424594332:margin-bottom: 10px; 1678424594333:} 1678424594334:ol.no-numbers { 1678424594335:list-style-type: none; 1678424594338:} 1678424594341:") 1678424594342:), 1678424594344:h3(style = "font-weight: bold; margin-top: 0; margin-bottom: 10px; font-size: 20px;color: #007bff;", "Pro Tips for Using Our Dashboard:"), 1678424594345:tags$ol( 1678424594346:class = "no-numbers", 1678424594348:style = "margin-top: 0; margin-bottom: 0; font-size: 20px;", 1678424594349:tags$li( 1678424594350:style = "margin-bottom: 15px;", 1678424594352:tags$span(class = "number-circle", "1"), 1678424594353:icon("info-circle", lib = "font-awesome"), 1678424594354:"Understand the data source, time period, and units." 1678424594355:), 1678424594356:tags$li( 1678424594357:style = "margin-bottom: 15px;", 1678424594358:tags$span(class = "number-circle", "2"), 1678424594359:icon("chart-bar", lib = "font-awesome"), 1678424594361:"View rainfall overview for summary information." 1678424594362:), 1678424594363:tags$li( 1678424594364:style = "margin-bottom: 15px;", 1678424594365:tags$span(class = "number-circle", "3"), 1678424594366:icon("chart-line", lib = "font-awesome"), 1678424594367:"Check seasonal analysis for trends and patterns." 1678424594369:), 1678424594370:tags$li( 1678424594371:style = "margin-bottom: 15px;", 1678424594372:tags$span(class = "number-circle", "4"), 1678424594373:icon("calendar", lib = "font-awesome"), 1678424594374:"Adjust time period for analysis." 1678424594376:), 1678424594377:tags$li( 1678424594378:style = "margin-bottom: 5px;", 1678424594379:tags$span(class = "number-circle", "5"), 1678424594380:icon("chart-area", lib = "font-awesome"), 1678424594381:"Compare data from different time periods." 1678424594382:), 1678424594384:tags$li( 1678424594385:style = "margin-bottom: 5px;", 1678424594386:tags$span(class = "number-circle", "6"), 1678424594387:icon("sliders-h", lib = "font-awesome"), 1678424594388:"Use filters to refine data analysis." 1678424594390:), 1678424594391:tags$li( 1678424594392:style = "margin-bottom: 0;", 1678424594393:tags$span(class = "number-circle", "7"), 1678424594395:icon("bullseye", lib = "font-awesome"), 1678424594396:"Interpret data for trends and patterns." 1678424594397:) 1678424594398:), 1678424594399:br(), 1678424594400:div( 1678424594401:class = "rainfall-plots", 1678424594403:h2("Rainfall Plots"), 1678424594404:p("Explore the different ways to visualize rainfall data with our dashboard. Here are some examples:"), 1678424594405:br(), 1678424594406:div( 1678424594407:class = "plot-section", 1678424594408:h3("Annual Plot"), 1678424594410:p("This chart shows the total amount of rainfall for each year in the selected date range. It can help users understand the general trend of rainfall over the years.") 1678424594411:), 1678424594412:div( 1678424594413:class = "plot-section", 1678424594414:h3("Daily Plot"), 1678424594416:p("This plot shows the amount of rainfall for each day in the selected date range. It can help users identify days with heavy rainfall, which may be useful for flood forecasting.") 1678424594417:), 1678424594418:div( 1678424594419:class = "plot-section", 1678424594420:h3("Monthly Plot"), 1678424594422:p("This plot displays the total amount of rainfall for each month in the selected date range. It can help users understand the monthly distribution of rainfall and identify any patterns or trends.") 1678424594423:), 1678424594424:div( 1678424594425:class = "plot-section", 1678424594426:h3("Rainy day Plot"), 1678424594431:p("This plot helps to identify the frequency of rainy days for each month in a given time period.") 1678424594432:), 1678424594433:div( 1678424594435:class = "plot-section", 1678424594436:h3("Seasonal Decomposition Plot"), 1678424594437:p("This plot decomposes a rainfall time series into its components, including trend, seasonal, and residual, and is useful in understanding the pattern of seasonality and trend over time.") 1678424594438:), 1678424594440:div( 1678424594441:class = "plot-section", 1678424594442:h3("Seasonal Plot"), 1678424594443:p("A seasonal plot is a type of data visualization that displays data over time, highlighting patterns and seasonal fluctuations in the data. It is commonly used in time series analysis.") 1678424594445:) 1678424594446:), 1678424594447:br(), 1678424594448:h2("About Kozhikode"), 1678424594450:p("The selected study area of Kozhikode district in Kerala State, India, is located in the humid tropical region, which receives abundant rainfall of over 3000 mm annually, three times higher than the Indian national average. The district is situated between North latitudes 11° 08′ to 11° 50′ and East longitudes 75° 30′ to 76° 8′, covering parts of Survey of India Toposheets 58 A and 49 M. Kozhikode district is bordered by Kannur district to the north, Wayanad district to the east, Malapuram district to the south, and the Arabian Sea to the west. These factors contribute to the unique climatic conditions in the area, making it a vital region to monitor and analyze rainfall patterns."), 1678424594451:br(), 1678424594452:h2("About CWRDM"), 1678424594454:p("The Centre for Water Resources Development and Management (CWRDM) plays a critical role in managing water resources in Kerala, where rainfall patterns can be unpredictable and extreme. CWRDM's research and development activities aim to understand the impact of rainfall on water resources, develop sustainable water management strategies, and provide technical support to government agencies and non-governmental organizations. CWRDM's hydrological and meteorological data collection and analysis systems provide valuable information on rainfall patterns, which can be used to forecast floods and droughts, and develop water conservation and management plans. CWRDM's expertise in water resources management, combined with its advanced research and development capabilities, makes it a valuable resource in addressing the challenges of managing water resources in a changing climate.") 1678424594455:) 1678424594457:) 1678424594458:) 1678424594459:), 1678424594460:tabPanel(tags$h3("Rainfall Overview", style = "color: #fff; background-color: #007bff; padding: 10px;"), 1678424594463:sidebarLayout( 1678424594464:sidebarPanel( 1678424594465:dateRangeInput("date_range", "Select Date Range:", 1678424594467:start = min(rainfall_data$Date), 1678424594468:end = max(rainfall_data$Date)), 1678424594469:selectInput("month_range", "Select Month Range:", 1678424594470:choices = c("All", month.name[1:12]), 1678424594472:selected = "All"), 1678424594473:selectInput("monthly_slicer", "Select a Month:", 1678424594474:choices = c("", month.name[1:12])), 1678424594476:actionButton("reset", "Reset Date and Month Range"), 1678424594477:selectInput("season", label = "Select Season:", 1678424594478:choices = c("All Seasons", "Winter", "Summer", "South West Monsoon", "Post Monsoon"), 1678424594479:selected = "All Seasons") 1678424594481:), 1678424594482:mainPanel( 1678424594483:fluidRow( 1678424594485:column(width = 6, plotOutput("annual_plot")), 1678424594486:column(width = 6, plotlyOutput("monthly_trend")) 1678424594487:), 1678424594489:fluidRow( 1678424594490:column(width = 6, plotlyOutput("daily_plot")), 1678424594492:column(width = 6, plotlyOutput("monthly_plot")) 1678424594493:) 1678424594494:) 1678424594496:)), 1678424594497:tabPanel(tags$h3("Seasonal Analysis", style = "color: #fff; background-color: #007bff; padding: 10px;"), 1678424594500:sidebarLayout( 1678424594501:sidebarPanel( 1678424594503:selectInput("season", label = "Select Season:", 1678424594504:choices = c("All Seasons", "Winter", "Summer", "South West Monsoon", "Post Monsoon"), 1678424594505:selected = "All Seasons"), 1678424594507:actionButton("reset_season", "Reset Seasonal Slicer") 1678424594508:), 1678424594509:mainPanel( 1678424594511:tabsetPanel( 1678424594512:type = "tabs", 1678424594514:tabPanel("Time Series Plot", plotOutput("tsplot")), 1678424594515:tabPanel("Histogram", plotOutput("histogram")), 1678424594516:tabPanel("Boxplot", plotOutput("boxplot")), 1678424594518:tabPanel("Seasonal Decomposition", plotOutput("decomposition")) 1678424594519:) 1678424594521:) 1678424594522:)), 1678424594523:tabPanel(tags$h3("Contact Us", style = "color: #fff; background-color: #007bff; padding: 10px;"), 1678424594526:fluidPage( 1678424594528:titlePanel(tags$h1("Water is not just a resource, it's the source of life. - Rajendra Singh", style = "font-size: 36px;color: #1f2d3d;")), 1678424594530:mainPanel( 1678424594532:tags$style(type="text/css", " 1678424594533:h2 {color: #007bff; font-size: 24px;} 1678424594536:h3 {color: #6c757d; font-size: 20px; margin-top: 30px;} 1678424594539:p {font-size: 18px; line-height: 1.5;} 1678424594542:.contact-info {border: 1px solid #28a745; padding: 10px; background-color: #d4edda; border-radius: 5px;} 1678424594546:.about-panel {background-color: #f8f9fa; padding: 20px; border-radius: 5px; box-shadow: 2px 2px 5px #888888;} 1678424594550:.data-source {font-style: italic; color: #6c757d; margin-top: 10px;} 1678424594553:"), 1678424594554:div(class = "about-panel", 1678424594556:h3(style="color: #007bff;", "Data Source"), 1678424594558:p("The meteorological data used in this dashboard is collected from the Observatory located at CWRDM."), 1678424594559:p(class = "data-source", "Source: CWRDM"), 1678424594561:br(), 1678424594562:h3(style="color: #007bff;", "Author"), 1678424594564:p("This Rainfall Analysis Dashboard was created by Dr. Naveena K, a Scientist at CWRDM, with expert guidance from Dr. Surendran U."), 1678424594566:br(), 1678424594567:h3(style="color: #007bff;", "Contact"), 1678424594569:div(class = "contact-info", 1678424594571:p("Dr. Naveena K"), 1678424594573:p("Scientist, LWMRG, CWRDM"), 1678424594574:p("Email: naveenak@cwrdm.org")) 1678424594576:)) 1678424594577:)), 1678424594579:) 1678424594796:# Define custom theme 1678424594797:theme_custom <- function() { 1678424594798:theme_bw(base_size = 14) + 1678424594799:theme(panel.grid.major = element_blank(), 1678424594800:panel.grid.minor = element_blank(), 1678424594801:axis.line = element_line(colour = "black",size = 12), 1678424594802:axis.text = element_text(colour = "black",size = 12), 1678424594803:axis.title = element_text(colour = "black", size = 16), 1678424594804:plot.title = element_text(colour = "black", size = 20), 1678424594805:plot.background = element_rect(fill = ""), 1678424594806:panel.background = element_rect(fill = "white")) 1678424594807:} 1678424594808:# Define server logic 1678424594809:server <- function(input, output, session) { 1678424594810:# Filter data based on selected date range and month range 1678424594811:filtered_data <- reactive({ 1678424594812:d <- rainfall_data %>% 1678424594813:filter(Date >= input$date_range[1], Date <= input$date_range[2]) 1678424594814:if (nrow(d) == 0) { 1678424594815:return(data.frame()) 1678424594816:} 1678424594817:if (input$month_range != "All") { 1678424594818:month_num <- match(input$month_range, month.name) 1678424594819:d <- d %>% filter(Month == month_num) 1678424594820:} 1678424594821:if (input$monthly_slicer != "") { 1678424594822:month_num <- match(input$monthly_slicer, month.name) 1678424594823:d <- d %>% filter(Month == month_num) 1678424594824:} 1678424594825:d 1678424594826:}) 1678424594828:##monthly rainyday plot 1678424594829:output$monthly_plot <- renderPlotly({ 1678424594830:filtered_data_monthly <- filtered_data() %>% 1678424594831:mutate(Rainy_Day = ifelse(rainfall > 2.5, 1, 0)) %>% 1678424594832:group_by(Year, Month) %>% 1678424594833:summarise(Total_Rainy_Days = sum(Rainy_Day), .groups = "drop") %>% 1678424594834:ungroup() 1678424594835:if (nrow(filtered_data_monthly) == 0) { 1678424594836:return(NULL) 1678424594837:} 1678424594838:if (input$monthly_slicer != "") { 1678424594840:month_num <- match(input$monthly_slicer, month.name) 1678424594841:filtered_data_monthly <- filtered_data_monthly %>% filter(Month == month_num) 1678424594842:} 1678424594843:# Define a color palette based on the number of months 1678424594844:colors <- colorRampPalette(brewer.pal(n = 12, name = "Set3")) 1678424594846:# Set the color of the bars based on the month 1678424594847:colorscale <- colors(length(unique(filtered_data_monthly$Month))) 1678424594848:p <- plot_ly(filtered_data_monthly, x = ~as.Date(paste(Year, Month, "1", sep = "-")), y = ~Total_Rainy_Days, 1678424594849:type = "bar", marker = list(color = colorscale), showlegend = FALSE) 1678424594851:p %>% layout(xaxis = list(title = "Date",font = list(size = 12, color = "black", family = "Arial Bold")), 1678424594852:yaxis = list(title = "Total Rainy Days",font = list(size = 12, color = "black", family = "Arial Bold")), 1678424594853:title = list(text = "Monthly Rainy Days", font = list(size = 18, color = "black", family = "Arial Bold")), 1678424594854:margin = list(l = 60, r = 10, t = 80, b = 50), 1678424594855:plot_bgcolor = "", 1678424594856:paper_bgcolor = "white") 1678424594857:}) 1678424594859:# Annual rainfall plot 1678424594860:output$annual_plot <- renderPlot({ 1678424594861:filtered_data_annual <- filtered_data() %>% 1678424594862:group_by(Year) %>% 1678424594864:summarise(Total_Rainfall = sum(rainfall), .groups = "drop") %>% 1678424594865:ungroup() 1678424594866:if (nrow(filtered_data_annual) == 0) { 1678424594867:return(NULL) 1678424594869:} 1678424594870:avg_rainfall <- mean(filtered_data_annual$Total_Rainfall) 1678424594872:min_year <- min(filtered_data_annual$Year) 1678424594874:plot <- ggplot(filtered_data_annual, aes(x = Year, y = Total_Rainfall, fill = Total_Rainfall)) + 1678424594875:geom_col() + 1678424594876:scale_fill_gradient(low = "blue", high = "lightblue") + 1678424594877:geom_hline(yintercept = avg_rainfall, color = "red", linetype = "dashed") + 1678424594879:annotate("text", x = min_year, y = avg_rainfall, label = "Average", color = "red", size = 3) + 1678424594880:labs(title = "Annual Rainfall", 1678424594881:x = "Year", 1678424594882:y = "Rainfall (mm)", 1678424594884:size = 14) + 1678424594885:theme(plot.background = element_rect(fill = "white", color = NA), 1678424594886:panel.background = element_blank(), 1678424594887:plot.title = element_text(size = 20), 1678424594889:legend.position = "none", 1678424594890:plot.margin = unit(c(1,1,1,1), "cm")) + 1678424594891:stat_smooth(method = "loess", formula = y ~ x, se = FALSE, color = "black") 1678424594893:plot 1678424594894:}) 1678424594896:# Monthly rainfall trend plot 1678424594897:output$monthly_trend <- renderPlotly({ 1678424594899:filtered_data_monthly <- filtered_data() %>% 1678424594900:group_by(Year, Month) %>% 1678424594901:summarise(Total_Rainfall = sum(rainfall), .groups = "drop") %>% 1678424594903:ungroup() 1678424594905:if (nrow(filtered_data_monthly) == 0) { 1678424594906:return(NULL) 1678424594907:} 1678424594909:# Calculate average rainfall 1678424594911:avg_rainfall <- mean(filtered_data_monthly$Total_Rainfall) 1678424594913:# Calculate linear regression 1678424594914:lm_model <- lm(Total_Rainfall ~ ymd(paste0(Year, "-", Month, "-01")), data = filtered_data_monthly) 1678424594915:r_squared <- round(summary(lm_model)$r.squared, 2) 1678424594917:eq <- paste0("y = ", round(lm_model$coefficients[1], 2), " + ", round(lm_model$coefficients[2], 2), "x") 1678424594919:plot <- ggplot(filtered_data_monthly, aes(x = as.Date(paste0(Year, "-", Month, "-01")), y = Total_Rainfall)) + 1678424594920:geom_line(color = "blue") + 1678424594922:geom_smooth(method = "lm", se = FALSE, color = "red", formula = y ~ x) + 1678424594923:labs(title = paste0("Monthly Rainfall Trend - Average Rainfall: ", round(avg_rainfall, 2), " mm"), 1678424594925:x = "Date", 1678424594926:y = "Rainfall (mm)", 1678424594927:color = "Trend") + 1678424594929:theme_bw()+ 1678424594930:theme(plot.title = element_text(size = 12)) + 1678424594932:annotate("text", 1678424594933:x = as.Date(paste0(max(filtered_data_monthly$Year), "-", max(filtered_data_monthly$Month), "-01")), 1678424594935:y = max(filtered_data_monthly$Total_Rainfall), 1678424594936:label = paste0("R-squared: ", round(r_squared, 2), " "), 1678424594938:hjust = 1, vjust = 1, size = 3) + 1678424594939:annotate("text", 1678424594940:x = as.Date(paste0(min(filtered_data_monthly$Year), "-", min(filtered_data_monthly$Month), "-01")), 1678424594942:y = max(filtered_data_monthly$Total_Rainfall), 1678424594943:label = paste0(" Average:",round(avg_rainfall, 1),"mm"), 1678424594945:hjust = 0, vjust = 1, size = 3) + 1678424594947:annotate("text", 1678424594948:x = as.Date(paste0(max(filtered_data_monthly$Year),"-",max(filtered_data_monthly$Month), "-01")), 1678424594950:y = 0.9 * max(filtered_data_monthly$Total_Rainfall), 1678424594951:label = paste0("y=",round(lm_model$coefficients[1], 1), 1678424594953:"+",round(lm_model$coefficients[2], 1),"x"," "), 1678424594954:size = 3, 1678424594955:hjust = 0.5, 1678424594957:vjust = 1) 1678424594959:plotly::ggplotly(plot) %>% 1678424594961:layout(title = "Monthly Rainfall Plot", 1678424594962:xaxis = list(title = "Date"), 1678424594964:yaxis = list(title = "Rainfall (mm)")) 1678424594965:}) 1678424594967:# Daily rainfall plot 1678424594968:output$daily_plot <- renderPlotly({ 1678424594970:filtered_data_daily <- filtered_data() %>% 1678424594971:mutate(Date = as.Date(Date)) %>% 1678424594973:group_by(Date) %>% 1678424594974:summarise(Total_Rainfall = sum(rainfall), .groups = "drop") 1678424594977:if (nrow(filtered_data_daily) == 0) { 1678424594978:return(NULL) 1678424594984:} 1678424594987:p <- plot_ly(filtered_data_daily, x = ~Date, y = ~Total_Rainfall, 1678424594988:type = "scatter", mode = "lines+markers", marker = list(size = 6), showlegend = FALSE) 1678424594991:p %>% layout(xaxis = list(title = "Date", font = list(size = 12, color = "black", family = "Arial Bold")), 1678424594992:yaxis = list(title = "Total Rainfall (mm)", font = list(size = 12, color = "black", family = "Arial Bold")), 1678424594994:title = list(text = "Daily Rainfall", font = list(size = 18, color = "black", family = "Arial Bold")), 1678424594996:margin = list(l = 60, r = 10, t = 80, b = 50), 1678424594997:plot_bgcolor = "", 1678424594999:paper_bgcolor = "white") 1678424595000:}) 1678424595003:# Filter data based on region and season inputs 1678424595005:# Filter data based on selected season 1678424595006:filtered_data <- reactive({ 1678424595008:if (input$season == "All Seasons") { 1678424595009:rainfall_data 1678424595011:} else { 1678424595013:subset(rainfall_data, Season == input$season) 1678424595014:} 1678424595016:}) 1678424595018:output$tsplot <- renderPlot({ 1678424595020:plot(filtered_data()$Date, filtered_data()$rainfall, type = "l", 1678424595022:col = "blue", lwd = 2, 1678424595023:main = "Rainfall Time Series Plot", 1678424595025:xlab = "Date", ylab = "Rainfall (mm)", 1678424595026:cex.axis = 1.2, cex.lab = 1.4) 1678424595028:legend("topright", legend = "", col = "blue", lwd = 2, bty = "n") 1678424595030:grid(col = "grey", lty = "dotted") 1678424595031:}) 1678424595034:output$histogram <- renderPlot({ 1678424595035:ggplot(data = filtered_data(), aes(x = rainfall)) + 1678424595037:geom_histogram(fill = "#0072B2", color = "#0072B2", alpha = 0.5) + 1678424595038:geom_vline(aes(xintercept = mean(rainfall)), 1678424595040:color = "#D55E00", linetype = "dashed", size = 1) + 1678424595042:labs(title = "Rainfall Histogram", x = "Rainfall (mm)", y = "Frequency") + 1678424595043:theme_bw() + 1678424595045:theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) 1678424595047:}) 1678424595048:###boxplot 1678424595050:output$boxplot <- renderPlot({ 1678424595051:ggplot(data = filtered_data(), aes(x = Season, y = rainfall, fill = Season)) + 1678424595053:geom_boxplot(alpha = 0.7, outlier.color = NA) + 1678424595055:geom_point(aes(x = Season, y = rainfall)) + 1678424595056:labs(title = "Rainfall Boxplot", x = "Season", y = "Rainfall (mm)", fill = "Season", 1678424595058:title.size = 20, x.text.size = 14, y.text.size = 14, legend.title.size = 14, 1678424595060:legend.text.size = 12) + 1678424595061:theme_bw(base_size = 14) + 1678424595063:theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 1678424595065:legend.position = "bottom", legend.direction = "horizontal") 1678424595066:}) 1678424595068:##decomposition plot 1678424595070:output$decomposition <- renderPlot({ 1678424595072:ts_data <- ts(filtered_data()$rainfall, frequency = 12) 1678424595073:decompose_data <- decompose(ts_data) 1678424595076:# Convert decomposed data into a data frame 1678424595078:df <- data.frame( 1678424595079:Date = time(ts_data), 1678424595081:Observed = decompose_data$x, 1678424595083:Seasonal = decompose_data$seasonal, 1678424595085:Trend = decompose_data$trend, 1678424595086:Random = decompose_data$random 1678424595088:) 1678424595090:df_long <- tidyr::pivot_longer(df, -Date, names_to = "Component", values_to = "Value") 1678424595092:# Plot using ggplot 1678424595094:ggplot(df_long, aes(x = Date, y = Value, color = Component)) + 1678424595096:geom_line() + 1678424595098:facet_wrap(~Component, ncol = 1, scales = "free_y") + 1678424595103:labs(title = "Rainfall Seasonal Decomposition", x = "", y = "Rainfall (mm)", 1678424595104:color = "Component") + 1678424595106:theme_bw(base_size = 16) + 1678424595108:theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 1678424595110:legend.title = element_text(size = 18), 1678424595112:legend.text = element_text(size = 16), 1678424595113:plot.title = element_text(size = 20, face = "bold"), 1678424595115:axis.title = element_text(size = 18, face = "bold"), 1678424595117:axis.text = element_text(size = 12)) 1678424595119:}) 1678424595121:#Reset button 1678424595123:observeEvent(input$reset, { 1678424595125:updateDateRangeInput(session, "date_range", 1678424595126:start = min(rainfall_data$Date), 1678424595128:end = max(rainfall_data$Date)) 1678424595130:updateSelectInput(session, "month_range", selected = "All") 1678424595132:updateSelectInput(session, "monthly_slicer", selected = "") 1678424595133:}) 1678424595135:#reset button 1678424595138:#reset button 1678424595140:observeEvent(c(input$reset, input$reset_season), { 1678424595142:updateSelectInput(session, "season", selected = "All Seasons") 1678424595143:}) 1678424595145:} 1678424595149:#Run the application 1678424595150:shinyApp(ui = ui, server = server) 1678425009503:source('C:/GEOMATICS 23-01-2021/RServer/test.R') 1678446382373:source('C:/GEOMATICS 23-01-2021/RServer/test.R') 1678446424514:install.packages("gganimate") 1678446426086:source('C:/GEOMATICS 23-01-2021/RServer/test.R') 1678446527068:library(shiny); source('C:/GEOMATICS 23-01-2021/RServer/test.R') 1678446542433:source('C:/GEOMATICS 23-01-2021/RServer/test.R') 1678446556714:# Read the daily rainfall data 1678446556715:rainfall_data <- read.csv("rainfall_data.csv") 1678446590546:setwd("C:/GEOMATICS 23-01-2021/RServer/R") 1678446594262:source('C:/GEOMATICS 23-01-2021/RServer/test.R') 1678448046573:source('C:/GEOMATICS 23-01-2021/RServer/test.R') 1678448067343:source('C:/GEOMATICS 23-01-2021/RServer/test.R') 1678448082510:source('C:/GEOMATICS 23-01-2021/RServer/test.R') 1678448117358:source('C:/GEOMATICS 23-01-2021/RServer/test.R') 1678448196304:source('C:/GEOMATICS 23-01-2021/RServer/test.R') 1678448259962:source('C:/GEOMATICS 23-01-2021/RServer/test.R') 1678448283452:setwd("C:/GEOMATICS 23-01-2021/RServer/R") 1678448286211:source('C:/GEOMATICS 23-01-2021/RServer/test.R') 1678448434851:setwd("C:/GEOMATICS 23-01-2021/RServer/R") 1678448440947:source('C:/GEOMATICS 23-01-2021/RServer/test.R') 1678947531848:source('C:/GEOMATICS 23-01-2021/RServer/test.R') 1678947553944:install.packages("reactable") 1678947589043:source('C:/GEOMATICS 23-01-2021/RServer/test.R') 1678955297229:source('C:/GEOMATICS 23-01-2021/RServer/test.R')