fixed whitespace issue in subchunkify
This commit is contained in:
parent
b6c576ca57
commit
95633a553c
|
|
@ -20,6 +20,8 @@ for arg in "$@"; do
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "Weeks ago: $weeks_ago"
|
||||||
|
|
||||||
# Check if required arguments are set
|
# Check if required arguments are set
|
||||||
if [ -z "$weeks_ago" ] || [ -z "$data_dir" ]; then
|
if [ -z "$weeks_ago" ] || [ -z "$data_dir" ]; then
|
||||||
echo "Missing arguments. Use: build_mosiac.sh --weeks_ago=3 --data_dir=chemba"
|
echo "Missing arguments. Use: build_mosiac.sh --weeks_ago=3 --data_dir=chemba"
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ subchunkify <- function(g, fig_height=7, fig_width=5) {
|
||||||
), collapse = '')
|
), collapse = '')
|
||||||
|
|
||||||
sub_chunk <- paste0("
|
sub_chunk <- paste0("
|
||||||
`","``{r sub_chunk_", floor(runif(1) * 10000), ", fig.height=", fig_height, ", fig.width=", fig_width, ", echo=FALSE}",
|
`","``{r sub_chunk_", floor(runif(1) * 10000), ", fig.height=", fig_height, ", fig.width=", fig_width, ", echo=FALSE}",
|
||||||
"\n(",
|
"\n(",
|
||||||
g_deparsed
|
g_deparsed
|
||||||
, ")()",
|
, ")()",
|
||||||
|
|
@ -283,36 +283,10 @@ cum_ci_plot <- function(pivotName){
|
||||||
max_date = max(Date),
|
max_date = max(Date),
|
||||||
days = max_date - min_date)
|
days = max_date - min_date)
|
||||||
|
|
||||||
# perfect_pivot_raw <- CI_quadrant %>% group_by(Field) %>% filter(Field == "5.1" & season == "2022") %>%
|
|
||||||
# group_by(DOY) %>% summarise(cumulative_CI = mean(cumulative_CI)) %>% mutate(CI_rate = cumulative_CI/DOY) %>%
|
|
||||||
# mutate(mean_rolling10 = rollapplyr(CI_rate , width = 10, FUN = mean, partial = TRUE))
|
|
||||||
|
|
||||||
unique_seasons <- unique(date_preperation_perfect_pivot$season)
|
unique_seasons <- unique(date_preperation_perfect_pivot$season)
|
||||||
|
|
||||||
# if(length(unique_seasons) == 3) {
|
|
||||||
# unique_seasons <- unique_seasons[c(2,3)]
|
|
||||||
# } else if(length(unique_seasons) == 4) {
|
|
||||||
# unique_seasons <- unique_seasons[c(3,4)]
|
|
||||||
# } else {
|
|
||||||
# unique_seasons <- unique_seasons
|
|
||||||
# }
|
|
||||||
|
|
||||||
# perfect_pivot <- perfect_pivot_raw
|
g <- ggplot(data= data_ci2) +
|
||||||
#
|
|
||||||
# for (s in unique_seasons) {
|
|
||||||
# season_dates <- seq(from = date_preperation_perfect_pivot$min_date[date_preperation_perfect_pivot$season == s],
|
|
||||||
# to = date_preperation_perfect_pivot$min_date[date_preperation_perfect_pivot$season == s] + nrow(perfect_pivot_raw) - 1,
|
|
||||||
# by = "1 day")
|
|
||||||
# col_name <- as.character(s)
|
|
||||||
# perfect_pivot <- dplyr::bind_cols(perfect_pivot, tibble(!!col_name := season_dates))
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# perfect_pivot <- perfect_pivot %>%
|
|
||||||
# pivot_longer(cols = -c("DOY", "cumulative_CI", "CI_rate", "mean_rolling10"),
|
|
||||||
# names_to = "season", values_to = "Date")
|
|
||||||
|
|
||||||
g <- ggplot(data= data_ci2 %>% filter(season %in% unique_seasons)) +
|
|
||||||
# facet_wrap(~Year, scales = "free_x") +
|
|
||||||
geom_line( aes(Date, mean_rolling10, col = subField)) +
|
geom_line( aes(Date, mean_rolling10, col = subField)) +
|
||||||
# geom_line(data= perfect_pivot, aes(Date , mean_rolling10, col = "Model CI (p5.1 Data 2022, \n date x axis is fictive)"), lty="11",size=1) +
|
# geom_line(data= perfect_pivot, aes(Date , mean_rolling10, col = "Model CI (p5.1 Data 2022, \n date x axis is fictive)"), lty="11",size=1) +
|
||||||
labs(title = paste("14 day rolling MEAN CI rate - Pivot ", pivotName))+
|
labs(title = paste("14 day rolling MEAN CI rate - Pivot ", pivotName))+
|
||||||
|
|
@ -323,7 +297,6 @@ cum_ci_plot <- function(pivotName){
|
||||||
legend.title = element_text(size = 8),
|
legend.title = element_text(size = 8),
|
||||||
legend.text = element_text(size = 8)) +
|
legend.text = element_text(size = 8)) +
|
||||||
guides(color = guide_legend(nrow = 2, byrow = TRUE))
|
guides(color = guide_legend(nrow = 2, byrow = TRUE))
|
||||||
# options(repr.plot.width = 2, repr.plot.height = 2)
|
|
||||||
subchunkify(g, 3.2, 10)
|
subchunkify(g, 3.2, 10)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -375,40 +348,42 @@ tm_shape(CI, unit = "m")+
|
||||||
```
|
```
|
||||||
|
|
||||||
\newpage
|
\newpage
|
||||||
|
|
||||||
```{r plots_ci_estate, eval=FALSE, fig.height=3.8, fig.width=10, message=FALSE, warning=FALSE, include=FALSE, results='asis'}
|
```{r plots_ci_estate, eval=FALSE, fig.height=3.8, fig.width=10, message=FALSE, warning=FALSE, include=FALSE, results='asis'}
|
||||||
# # pivots <- AllPivots_merged %>% filter(pivot != c("1.1", "1.17"))
|
# # pivots <- AllPivots_merged %>% filter(pivot != c("1.1", "1.17"))
|
||||||
pivots_estate <- AllPivots_merged %>% filter(pivot %in% c("1.1", "1.2", "1.3", "1.4", "1.6", "1.7", "1.8", "1.9", "1.10", "1.11", "1.12", "1.13", "1.14" , "1.16" , "1.17" , "1.18" , "6.1", "6.2", "DL1.1", "DL1.3")) %>% filter(pivot != "1.17")
|
pivots_estate <- AllPivots_merged %>% filter(Field %in% c("6.2")) #, "1.2", "1.3", "1.4")) #, "1.6", "1.7", "1.8", "1.9", "1.10", "1.11", "1.12", "1.13", "1.14" , "1.16" , "1.17" , "1.18" , "6.1", "6.2", "DL1.1", "DL1.3")) %>% filter(pivot != "1.17")
|
||||||
|
|
||||||
|
|
||||||
# pivots <- AllPivots_merged %>% filter(pivot != c("1.1", "1.17"))
|
# pivots <- AllPivots_merged %>% filter(pivot != c("1.1", "1.17"))
|
||||||
# pivots_estate <- AllPivots_merged %>% filter(pivot %in% c("1.1", "1.2", "1.7")) %>% filter(pivot != "1.17")
|
# pivots_estate <- AllPivots_merged %>% filter(pivot %in% c("1.1", "1.2", "1.7")) %>% filter(pivot != "1.17")
|
||||||
|
|
||||||
walk(pivots_estate$pivot, ~ {
|
|
||||||
|
walk(pivots_estate$Field, ~ {
|
||||||
|
cat("# Hello!!!")
|
||||||
cat("\n") # Add an empty line for better spacing
|
cat("\n") # Add an empty line for better spacing
|
||||||
ci_plot(.x)
|
ci_plot(.x)
|
||||||
# cum_ci_plot(.x)
|
# cum_ci_plot(.x)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```{r looping_over_sub_area, echo=FALSE, fig.height=3.8, fig.width=10, message=FALSE, warning=FALSE, results='asis', eval=TRUE}
|
||||||
```{r looping over sub_area, echo=FALSE, fig.height=3.8, fig.width=10, message=FALSE, warning=FALSE, results='asis'}
|
pivots_grouped <- AllPivots_merged # %>%
|
||||||
pivots_grouped <- AllPivots_merged %>%
|
# group_by(sub_area) %>%
|
||||||
group_by(sub_area) %>%
|
# arrange(sub_area) # Optional: arrange the groups alphabetically by sub_area
|
||||||
arrange(sub_area) # Optional: arrange the groups alphabetically by sub_area
|
|
||||||
|
|
||||||
# Iterate over each subgroup
|
# Iterate over each subgroup
|
||||||
for (subgroup in unique(pivots_grouped$sub_area)) {
|
for (subgroup in unique(pivots_grouped$sub_area)) {
|
||||||
cat("\n")
|
cat("# HELLO!!!")
|
||||||
cat("# Subgroup: ", subgroup, "\n") # Add a title for the subgroup
|
print(" PRINT")
|
||||||
|
# cat("\n")
|
||||||
|
# cat("# Subgroup: ", subgroup, "\n") # Add a title for the subgroup
|
||||||
subset_data <- filter(pivots_grouped, sub_area == subgroup)
|
subset_data <- filter(pivots_grouped, sub_area == subgroup)
|
||||||
cat('\\pagebreak')
|
# cat("\\pagebreak")
|
||||||
walk(subset_data$Field, ~ {
|
walk(subset_data$Field, ~ {
|
||||||
cat("\n") # Add an empty line for better spacing
|
# cat("\n") # Add an empty line for better spacing
|
||||||
ci_plot(.x)
|
ci_plot(.x)
|
||||||
cat("\n")
|
# cat("\n")
|
||||||
cum_ci_plot(.x)
|
cum_ci_plot(.x)
|
||||||
cat("\n")
|
# cat("\n")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
||||||
BIN
r_app/Rplots.pdf
BIN
r_app/Rplots.pdf
Binary file not shown.
Loading…
Reference in a new issue