The page jumping function works perfect. Thank you so much! I need to get that page but keep the page layout without change. Here is the real code used in the report generation. I want to click on any row in description column, say math, and jump to math page. Again, thanks much
---
title: ''
geometry: margin=2cm
output:
pdf_document:
latex_engine: xelatex
html_document: default
word_document: default
urlcolor: blue
classoption: landscape
---
```{r prelim, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
knitr::opts_chunk$set(autodep = TRUE)
knitr::opts_chunk$set(warning = FALSE)
knitr::opts_chunk$set(message = FALSE)
knitr::opts_chunk$set(dev = 'pdf', fig.width = 12, fig.height = 7)
library(glue)
library(dplyr)
library(tidyverse)
library(gridExtra)
library(ggplot2)
library(knitr)
library(kableExtra)
library(ggpubr)
library(cowplot)
```
```{r create_ds}
# summary page
sum_tbl <- data.frame(
stringsAsFactors = FALSE,
msr_cd = c("CAB-01", "CAB-03", "CAB-04", "CAB-05", "CAB-06"),
Measure_Name = c("Math",
"Physics",
"Chemistry",
"English",
"Music"),
Score = c(95.42, 94.737, 100, 0, 100),
St_Score = c(92.1302549822323,
84.095435198563,92.1090387374462,4.98731673760695,93.7851163857356),
Nat_Score = c(94.45295404814,
86.4454976303318,96,4.31482221334399,92.0296570898981),
pctle = c(68, 86, 100, 100, 100)
)
# trend plot
tre_tbl<-data.frame(
stringsAsFactors = FALSE,
YrQtr = c("2018Q3","2018Q3","2018Q4",
"2018Q4","2019Q1","2019Q1","2019Q2",
"2019Q2","2019Q3","2019Q3",
"2019Q4","2019Q4","2020Q1","2020Q1",
"2020Q2","2020Q2"),
group = c("Rate_Qtrly","Rate_Qtrly_Cert",
"Rate_Qtrly","Rate_Qtrly_Cert",
"Rate_Qtrly","Rate_Qtrly_Cert",
"Rate_Qtrly","Rate_Qtrly_Cert","Rate_Qtrly",
"Rate_Qtrly_Cert","Rate_Qtrly",
"Rate_Qtrly_Cert","Rate_Qtrly",
"Rate_Qtrly_Cert","Rate_Qtrly",
"Rate_Qtrly_Cert"),
rate = c(100,99.445725764452,100,
99.5072431551258,100,99.5243966883918,
100,99.4535890039029,98.5915492957747,
99.5167785234899,100,
99.5289961730939,100,99.6394917190177,100,
99.6281996281996)
)
# histogram
his_tbl<-data.frame(
Rate = c(99.669,99.487,100,100,99.475,99.452,
100,100,98.028,100,100,99.153,99.577,100,99.785,99.433,
100,100,99.441,100,98.778,99.56,100,99.446,100,99.234,
100,99.281,99.177,98.936,99.048,100,96.154,100,99.718,
99.481,99.765,99.811,100,100,100,100,97.544,99.457,
100,100,97.611,97.17,99.752,97.99,97.674,100,100,99.888,
100,99.419,100,99.76,100,99.754,100,99.287,97.273,
98.381,99.476,100,99.389,100,99.802,99.559,100,99.842,
100,100,100,99.438,100,99.855,99.769,100,100,99.707,100,
99.718,100,97.877,100,100,99.816,98.725,100,100,
99.378,100,99.825,99.512,99.827,99.677,100,98.983)
)
# data display
dp_tbl <- data.frame(
stringsAsFactors = FALSE,
Date_Range = c("2019Q3-2020Q2"),
Rate = c(99.669),
CountsByMeasure = c(1541L),
Rate_Year_ST = c(99.5400919816037),
Rate_Year_Cert = c(99.5730012435082),
pctle = c(39)
)
```
\pagebreak
**School ID: ** School 12345, IL
**Comparative Report: Subject Scores for School with National and State Comparison**
```{r sumpg, echo=FALSE, results='asis'}
sum_tbl$new_msr_nm <- paste0(sum_tbl$msr_cd," - ",sum_tbl$Measure_Name)
sum_tblt <- sum_tbl %>%
select(
"Subject Description"=new_msr_nm,
"School's Score"=Score,
"State Score"=St_Score,
"National Score"=Nat_Score,
"School Percentile"=pctle
)
sum_tblt %>%
kable(digits=1) %>% column_spec(1, width="11cm",border_left = TRUE) %>%
column_spec(2:4, width="1.8cm") %>%
column_spec(5,width="1.8cm",border_right = TRUE)%>%
kable_styling("bordered", font_size = 14)
cat("\n\\pagebreak\n")
```
**School ID: ** School 12345, IL
**Subject Name: ** Math
**Measure Description: ** Evaluation
**Link to QI Resources:** <http://rmarkdown.rstudio.com>
```{r mathpg, echo=F,results='asis'}
o1 <- ggplot(tre_tbl, aes(y=rate, x=YrQtr, group=group, color=group)) +
geom_point(size=3) +
geom_line(size=2) +
xlab(" ") + ylab("Score (%)") +
scale_colour_manual(name=" ", values=c(Rate_Qtrly_Cert="orange",Rate_Qtrly="blue"),
breaks=c("Rate_Qtrly","Rate_Qtrly_Cert"),
labels=c("School Scores","National Scores")) +
theme(legend.position = "bottom", axis.text.x = element_text(angle=30, hjust=1, vjust=.5))
o2 <- ggplot(his_tbl,aes(x=Rate, y=..count..)) +
geom_histogram(bins=50, fill="steelblue", color="white") +
xlab("Score (%)") + ylab("School Reporting") +
theme(title=element_text(size=11,face='bold'))
orgwide <- dp_tbl %>% select(
"Reporting Period"=Date_Range,
"School's Score"=Rate,
"Number of School Reporting"=CountsByMeasure,
"State Score"=Rate_Year_ST,
"National Score"=Rate_Year_Cert,
"School Percentile"=pctle)
orglong <- t(orgwide)
o3 <- ggtexttable(orglong, cols = NULL,
theme = ttheme("blank",
tbody.style = c(hjust=1, x=0.9)))
text <- paste(" ")
text.p <- ggparagraph(text = text, color="white")
top_row <- plot_grid(o3, text.p, align = 'h', rel_widths = c(10, 1), axis="l")
bottom_row <- plot_grid(o1, o2, align = 'h', rel_widths = c(1.5, 1.5), axis="l")
ggarrange(top_row, bottom_row, ncol = 1, nrow = 2, heights = c(.6, 1))
cat("\n\\pagebreak\n")
```
**School ID: ** School 12345, IL
**Subject Name: ** Physics
**Measure Description: ** Evaluation
**Link to QI Resources:** <http://rmarkdown.rstudio.com>
```{r phypg,echo=F,results='asis'}
o1 <- ggplot(tre_tbl, aes(y=rate, x=YrQtr, group=group, color=group)) +
geom_point(size=3) +
geom_line(size=2) +
xlab(" ") + ylab("Score (%)") +
scale_colour_manual(name=" ", values=c(Rate_Qtrly_Cert="orange",Rate_Qtrly="blue"),
breaks=c("Rate_Qtrly","Rate_Qtrly_Cert"),
labels=c("School Scores","National Scores")) +
theme(legend.position = "bottom", axis.text.x = element_text(angle=30, hjust=1, vjust=.5))
o2 <- ggplot(his_tbl,aes(x=Rate, y=..count..)) +
geom_histogram(bins=50, fill="steelblue", color="white") +
xlab("Score (%)") + ylab("School Reporting") +
theme(title=element_text(size=11,face='bold'))
orgwide <- dp_tbl %>% select(
"Reporting Period"=Date_Range,
"School's Score"=Rate,
"Number of School Reporting"=CountsByMeasure,
"State Score"=Rate_Year_ST,
"National Score"=Rate_Year_Cert,
"School Percentile"=pctle)
orglong <- t(orgwide)
o3 <- ggtexttable(orglong, cols = NULL,
theme = ttheme("blank",
tbody.style = c(hjust=1, x=0.9)))
text <- paste(" ")
text.p <- ggparagraph(text = text, color="white")
top_row <- plot_grid(o3, text.p, align = 'h', rel_widths = c(5, 1), axis="l")
bottom_row <- plot_grid(o1, o2, align = 'h', rel_widths = c(1.5, 1.5), axis="l")
ggarrange(top_row, bottom_row, ncol = 1, nrow = 2, heights = c(.6, 1))
cat("\n\\pagebreak\n")
```
**School ID: ** School 12345, IL
**Subject Name: ** Chemistry
**Measure Description: ** Evaluation
**Link to QI Resources:** <http://rmarkdown.rstudio.com>
```{r chepg, echo=F,results='asis'}
o1 <- ggplot(tre_tbl, aes(y=rate, x=YrQtr, group=group, color=group)) +
geom_point(size=3) +
geom_line(size=2) +
xlab(" ") + ylab("Score (%)") +
scale_colour_manual(name=" ", values=c(Rate_Qtrly_Cert="orange",Rate_Qtrly="blue"),
breaks=c("Rate_Qtrly","Rate_Qtrly_Cert"),
labels=c("School Scores","National Scores")) +
theme(legend.position = "bottom", axis.text.x = element_text(angle=30, hjust=1, vjust=.5))
o2 <- ggplot(his_tbl,aes(x=Rate, y=..count..)) +
geom_histogram(bins=50, fill="steelblue", color="white") +
xlab("Score (%)") + ylab("School Reporting") +
theme(title=element_text(size=11,face='bold'))
orgwide <- dp_tbl %>% select(
"Reporting Period"=Date_Range,
"School's Score"=Rate,
"Number of School Reporting"=CountsByMeasure,
"State Score"=Rate_Year_ST,
"National Score"=Rate_Year_Cert,
"School Percentile"=pctle)
orglong <- t(orgwide)
o3 <- ggtexttable(orglong, cols = NULL,
theme = ttheme("blank",
tbody.style = c(hjust=1, x=0.9)))
text <- paste(" ")
text.p <- ggparagraph(text = text, color="white")
top_row <- plot_grid(o3, text.p, align = 'h', rel_widths = c(10, 1), axis="l")
bottom_row <- plot_grid(o1, o2, align = 'h', rel_widths = c(1.5, 1.5), axis="l")
ggarrange(top_row, bottom_row, ncol = 1, nrow = 2, heights = c(.6, 1))
```