Project A
1000
209
501
290
15
200.04
7.92
Report
This is a report on 1000 enrollments.
The average score was 200.0383175.
The average grade was 7.917.
This report was generated on July 29, 2022.
Created by:
R version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
[4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
[7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.14.2 shiny_1.7.1 ggvis_0.4.7
[4] highcharter_0.9.4 openintro_2.3.0 usdata_0.2.0
[7] cherryblossom_0.1.0 airports_0.1.0 dplyr_1.0.9
[10] plotly_4.10.0 ggplot2_3.3.6 rpivotTable_0.3.0
[13] DT_0.23 knitr_1.39 flexdashboard_0.5.2
loaded via a namespace (and not attached):
[1] httr_1.4.3 sass_0.4.1 tidyr_1.2.0 jsonlite_1.8.0
[5] viridisLite_0.4.0 bslib_0.3.1 assertthat_0.2.1 TTR_0.24.3
[9] yaml_2.3.5 pillar_1.7.0 backports_1.4.1 lattice_0.20-45
[13] glue_1.6.2 rlist_0.4.6.2 digest_0.6.29 RColorBrewer_1.1-3
[17] promises_1.2.0.1 colorspace_2.0-3 htmltools_0.5.2 httpuv_1.6.5
[21] pkgconfig_2.0.3 broom_0.8.0 purrr_0.3.4 xtable_1.8-4
[25] scales_1.2.0 later_1.3.0 tzdb_0.3.0 tibble_3.1.7
[29] generics_0.1.2 farver_2.1.0 ellipsis_0.3.2 withr_2.5.0
[33] lazyeval_0.2.2 cli_3.3.0 quantmod_0.4.20 magrittr_2.0.3
[37] crayon_1.5.1 mime_0.12 evaluate_0.15 fansi_1.0.3
[41] xts_0.12.1 tools_4.2.0 hms_1.1.1 lifecycle_1.0.1
[45] stringr_1.4.0 munsell_0.5.0 compiler_4.2.0 jquerylib_0.1.4
[49] rlang_1.0.2 grid_4.2.0 htmlwidgets_1.5.4 crosstalk_1.2.0
[53] igraph_1.3.4 rmarkdown_2.14 gtable_0.3.0 curl_4.3.2
[57] R6_2.5.1 zoo_1.8-10 lubridate_1.8.0 fastmap_1.1.0
[61] utf8_1.2.2 readr_2.1.2 stringi_1.7.6 Rcpp_1.0.8.3
[65] vctrs_0.4.1 tidyselect_1.1.2 xfun_0.31
---
title: "flexdashboard Template"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
social: [ "twitter", "facebook", "menu"]
source_code: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(knitr)
library(DT)
library(rpivotTable)
library(ggplot2)
library(plotly)
library(dplyr)
library(openintro)
library(highcharter)
library(ggvis)
library(shiny)
```
```{r}
library(data.table)
n <- 1000
dt <- data.table(
id = 1:n
, score = rnorm(n, mean = 200, sd = 40)
, group = sample(c("A", "B", "C"), size = n, replace = TRUE, prob = c(0.2, 0.5, 0.3))
, grade = sample(1:15, size = n, replace = TRUE)
, state = sample(c("Tennessee", "Georgia", "Kentucky", "Alibama"), size = n, replace = TRUE)
)
```
```{r}
mycolors <- c("blue", "#FFC125", "darkgreen", "darkorange")
```
Interactive Data Visualization
=====================================
Row
-------------------------------------
### Project A Analysis
```{r}
valueBox(paste("Project A"), color = "#448833")
```
### Number of Enrollments
```{r}
valueBox(length(dt$id), icon = "fa-user")
```
### **Average Score**
```{r}
gauge(round(mean(dt$score),
digits = 2),
min = 0,
max = 350,
gaugeSectors(success = c(0, 150),
warning = c(150, 240),
danger = c(240, 350),
colors = c("green", "yellow", "red")))
```
### Group A
```{r}
valueBox(sum(dt$group == "A"), icon = 'fa-building')
```
### Group B
```{r}
valueBox(sum(dt$group == "B"), icon = 'fa-building')
```
### Group C
```{r}
valueBox(sum(dt$group == "C"), icon = 'fa-building')
```
Row
-------------------------------
### Enrollments By Group: Bar Plot
```{r}
p1 <- dt %>%
group_by(group) %>%
summarise(count = n()) %>%
plot_ly(x = ~group,
y = ~count,
color = "blue",
type = 'bar') %>%
layout(xaxis = list(title = "Number by Group"),
yaxis = list(title = 'Count'))
p1
```
### Pie Plot
```{r}
colors <- c("#009999", "#990099", "#999900")
p2 <- dt %>%
group_by(group) %>%
summarise(count = n()) %>%
filter(count>50) %>%
plot_ly(labels = ~group,
values = ~count,
marker = list(colors = colors)) %>%
add_pie(hole = 0.2) %>%
layout(xaxis = list(zeroline = F,
showline = F,
showticklabels = F,
showgrid = F),
yaxis = list(zeroline = F,
showline = F,
showticklabels=F,
showgrid=F))
p2
```
### Histogram/Bar Plot
```{r}
p3 <- plot_ly(dt,
x = ~grade,
y = ~score,
text = paste("Grade:", dt$grade,
"Score:",
dt$score),
type = "bar") %>%
layout(xaxis = list(title="Grade"),
yaxis = list(title = "Score"))
p3
```
Row
------------------------------------
### Scatter Plot
```{r}
p4 <- plot_ly(dt, x=~grade) %>%
add_markers(y = ~score,
text = ~paste("score: ", score),
showlegend = F) %>%
add_lines(y = ~fitted(loess(score ~ grade)),
name = "Loess Smoother",
color = I("#119999"),
showlegend = T,
line = list(width=5)) %>%
layout(xaxis = list(title = "Grade"),
yaxis = list(title = "Score"))
p4
```
### Box Plot
```{r}
dt %>%
group_by(group) %>%
ggvis(~group, ~score, fill = ~group) %>%
layer_boxplots()
```
Map
========================================
### Map
```{r}
library("dplyr")
library(highcharter)
data("USArrests", package = "datasets")
data("usgeojson")
USArrests <- mutate(USArrests, state = rownames(USArrests))
highchart() %>%
hc_title(text = "Violent Crime Rates by US State") %>%
hc_subtitle(text = "Source: USArrests data") %>%
hc_add_series_map(usgeojson, USArrests,
name = "Murder arrests (per 100,000)",
value = "Murder", joinBy = c("woename", "state"),
dataLabels = list(
enabled = TRUE,
format = "{point.properties.postalcode}"
)
) %>%
hc_colorAxis(stops = color_stops()) %>%
hc_legend(valueDecimals = 0, valueSuffix = "%") %>%
hc_mapNavigation(enabled = TRUE)
```
Data Table
========================================
```{r}
datatable(dt,
caption = "Data",
rownames = T,
filter = "top",
options = list(pageLength = 25))
```
Pivot Table
=========================================
```{r}
rpivotTable(dt,
aggregatorName = "Count",
cols= "grade",
rows = "group",
rendererName = "Heatmap")
```
Summary {data-orientation=columns}
===========================================
Column
-----------------------------------
### Max Grade
```{r}
valueBox(max(dt$grade),
icon = "fa-user" )
```
### Average Score
```{r}
valueBox(round(mean(dt$score),
digits = 2),
icon = "fa-area-chart")
```
### Average Grade
```{r}
valueBox(round(mean(dt$grade), digits = 2),
icon = "fa-area-chart")
```
Column
---------------------------
Report
* This is a report on `r length(dt$grade)` enrollments.
* The average score was `r mean(dt$score)`.
* The average grade was `r mean(dt$grade)`.
This report was generated on `r format(Sys.Date(), format = "%B %d, %Y")`.
About Report
========================================
Created by:
```{r}
sessionInfo()
```