climatets <- function(filename,num,plot=TRUE,s=2) {
##############################################
# function to set up temp data for climate series
# inputs: filename and sheet number
# output: returns cleaned data and plot
# written by: P.Kohli
# date: 4/13/24
##############################################
dataexcel <- read_excel(filename,sheet=num,range="D7:H77")
dataexcel <- dataexcel[-1,-2]
dataexcel <- filter(dataexcel, !is.na(dataexcel$Avg))
data <- dataexcel %>% mutate(Month=num)
if(plot==TRUE){
g <- data%>% ggplot(aes(Year, Avg))+ geom_line(size=s)
return(list(data,g))
}else{
return(data)
}
}
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
Jan.Warwick <- climatets("Climate_Northeast_WarwickRI.xlsx",1,TRUE,1)
## New names:
## • `` -> `...2`
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
Jan.Warwick.nna <- Jan.Warwick[[1]] %>% filter(!is.na(Avg))
p <- plot_ly(Jan.Warwick.nna , x = ~Year, y = ~Avg) %>%
add_lines() %>%
layout(yaxis = list(title = ""))
p