For this investigation we are going to use the sleepdata
data set from the lme4 package. Here is the head of the data frame:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ggplot boxplot groups of continuous x | |
### Daniel J. Hocking | |
I am trying to make a boxplot with ggplot2 in R where the x-axis in continous but their are paired boxplots for each value of on the x-axis based on another factor with two possible values. I want to make a plot where boxplots are arranged by number of survey years on the x-axis but paired by spatialTF (2 boxplots for every value of n_years) but n_years are not evenly spaced. | |
This plot gets the paired boxplots correct by year but the years on the x-axis are evenly spaced and don't reflect the actual (continuous) time between years. | |
``` | |
ggplot(df_converged, aes(factor(n_years), mean_N_est)) + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fetch temperature data | |
tbl_values <- left_join(tbl_series, | |
select(tbl_variables, variable_id, variable_name), | |
by=c('variable_id'='variable_id')) %>% | |
select(-file_id) %>% | |
filter(location_id %in% df_locations$location_id, | |
variable_name=="TEMP") %>% | |
left_join(tbl_values, | |
by=c('series_id'='series_id')) %>% | |
left_join(select(tbl_locations, location_id, location_name, latitude, longitude, featureid=catchment_id), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#purling is in the knitr package | |
library(knitr) | |
setwd("C:/ALR/Models/boo") #example using local windows directory, can easily switch | |
#it can be really simple | |
purl( "script1.Rmd", "script1.R" ) | |
#just specify the rmd filename, then r filename, with extensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################################################################### | |
# PROGRAM: download.prism | |
# USE: BATCH DOWNLOAD AND UNCOMPRESSION OF PRISM DAILY OR MONTHLY GRIDDED DATA | |
# PRISM URL: http://prism.nacse.org/ | |
# REQUIRES: >= R 3.0, RCurl | |
# | |
# ARGUMENTS: | |
# data.type TYPE OF CLIMATE DATA ("ppt","tmin","tmax","tmean") | |
# date.range A VECTOR WITH START AND END DATA IN y/m/d FORMAT | |
# time.step DEFINES TIMESTEP OF PRODUCT ("daily"/"monthly") |