Package 'tlShiny'

Title: Supplies essential functions to Teaching Lab dashboards
Description: A bunch of random functions I use in developing dashboards Needs to vastly reduce the number of dependencies at the moment.
Authors: Duncan Gates
Maintainer: Duncan Gates <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2024-11-01 06:11:05 UTC
Source: https://github.com/teachinglab/tlShiny

Help Index


Agree/Strongly agree

Description

Gets the percent that agree and strongly agree

Usage

agree_strongly_agree(data, question)

Arguments

data

the data

question

a string - the question to get the percentage for

Value

a string

Examples

## Not run: 
plot_agree |>
  agree_strongly_agree(question = "x")

## End(Not run)

Calculate nps score

Description

Calculate nps score

Usage

calc_nps(x)

Arguments

x

A vector of nps scores

Value

Returns the nps score With formula '


Verify email from vector

Description

Verifies that an email is in a list

Usage

check_email_approved(email, approved_emails_list)

Arguments

email

the email provided

approved_emails_list

the email to check the list for

Value

TRUE or FALSE


Verify email domain

Description

Verifies that an email is of a specified domain

Usage

check_email_domain(email, domain)

Arguments

email

the email provided

domain

the domain to check that it is from

Value

TRUE or FALSE


Contact Lead Graph Summary

Description

Returns a barchart for selections in the relevant questions of the contact lead survey

Usage

contact_lead_graph(data)

Arguments

data

the data to use

Value

prints a ggplot object


Course survey feedback graph dependent on race and content area

Description

Returns a barchart for selections in the relevant questions of the end of coaching survey

Usage

course_feedback_graph(data)

Arguments

data

the data to use

Value

prints a ggplot object


HTML/CSS Button Content Expander

Description

Creates a button that will expand or hide content

Usage

drop1(before = T, options, envir, name)

Arguments

before

button default, collapsed/not collapsed

options

unclear

envir

also unclear

name

chunk name

Value

html wrapper


End of Coaching feedback graph dependent on race and content area

Description

Returns a barchart for selections in the relevant questions of the end of coaching survey

Usage

end_coaching_feedback_graph(data)

Arguments

data

the data to use

Value

prints a ggplot object


File path

Description

Gives the file path without double slash bug

Usage

file.path2(..., fsep = .Platform$file.sep)

Arguments

...

The file path

fsep

the file separation

Value

fp a file path


Grade IPG Data

Description

function for grading different parts of the ipg forms

Usage

grade_ipg(x, type = "character")

Arguments

x

the data

type

character or numeric

Value

a percentage of correct either by checking 3 or 4 or yes


GT or ggplot maker

Description

makes a gt table with percent and n colored

Usage

gt_percent_n(
  df,
  column,
  custom_title,
  no_title = T,
  base_font = 10,
  heading_font = 14,
  custom_column_name = "",
  viz_type = "gt"
)

Arguments

df

the data frame

column

the column to get count and percent from

custom_title

the title for the table

no_title

make the table have no title

base_font

overall table font size

heading_font

title font size

custom_column_name

a custom name for the column

viz_type

gt by default, also has ggplot options like pie chart, waffle, or treemap

Value

a gt table


Create Teaching Lab theme to a gt table

Description

Create Teaching Lab theme to a gt table

Usage

gt_theme_tl(
  data,
  all_caps = F,
  align = "center",
  base_font = 16,
  heading_font = 20,
  ...
)

Arguments

data

An existing gt table object

all_caps

Whether or not to capitalize titles

align

Align options are "left", "center", "right"

base_font

the font size

heading_font

the title font size

...

Optional additional arguments to gt::table_options()

Value

Creates a gt theme as a pipeable function

Examples

mtcars |> utils::head() |> gt::gt() |> tlShiny::gt_theme_tl()

gtable_extract_grob

Description

Helper function to extract a grob from gtables by name.

Usage

gtable_extract_grob(g, pattern = "guide-box")

Arguments

g

the gtable to extract the grob

pattern

grob name or pattern to match

Value

g, a grob matching the specified pattern


gtable_remove_grob

Description

Helper function to remove grobs by name, from gtables

Usage

gtable_remove_grob(g, pattern = "guide-box")

Arguments

g

gtable with the grob removed

pattern

grob name or pattern to match

Value

g, with pattern removed.


Word highlighting

Description

Provides html formatted highlighting

Usage

highlight_fun(data, highlight = tlShiny::find_highlight(data))

Arguments

data

the data to highlight

highlight

the words to highlight

Details

#' @title Word highlighting #' @description Finds most common words in string #' @param string the string to evaluate #' @param n the number of words to find #' @param print whether or not to print the highlighted words #' @return a vector of strings #' #' @export find_highlight <- function(string, n = 3, print = F) stop_words <- tlShiny::stop_words |> dplyr::bind_rows(data.frame(word = tlShiny::na_df, lexicon = "TL_NA"))

txt_df <- data.frame(column_name = "txt") |>

highlight <- string |> na.omit() |> as.data.frame() |> dplyr::rename() |> tidytext::unnest_tokens(word, txt) |> # This makes sure to get rid of numbers in consideration for highlighting # By making sure as.numeric returns NA on words dplyr::filter(is.na(as.numeric(word))) |> # Get a count of words and sort dplyr::count(word, sort = T) |> # Get rid of generic (stop) words dplyr::anti_join(stop_words) |> # Get a user-specified number of words, or the default 3 utils::head(n) |> # Make this a vector dplyr::pull(word) |> # Suppress warnings from the as.numeric call suppressWarnings() |> suppressMessages()

if (print == T) print(highlight)

return(highlight)

Value

a vector of strings


HTML Text Wrapping

Description

Takes a string and inserts <br> at the requested intervals

Usage

html_wrap(string, n = 40)

Arguments

string

the string

n

the width of the string before a <br> tag

Value

the same string with <br> inserted at the requested interval

Examples

html_wrap("a random string that has about 40 characters in it")

Knowledge Assessment Graph Summary

Description

Creates a graph specifically for Knowledge Assessments in mid year reports

Usage

know_assess_summary(data, know_assess_filter)

Arguments

data

the data

know_assess_filter

the knowledge assessment to make plot for

Value

a ggplot


Knowledge Assessment Graph Question-level Summary

Description

Creates a graph specifically for Knowledge Assessments Scored by Question from Qualtrics

Usage

know_assess_summary_detailed(data, know_assess)

Arguments

data

the data

know_assess

the knowledge assessment to make plot for

Value

a ggplot


ELA IPG Chart Summary Maker

Description

Creates a chart to summarise the ELA IPG based on the round selected

Usage

make_ipg_ela_summary_chart(
  data,
  round = "Baseline (first observation of the year)"
)

Arguments

data

the data

round

the round of the IPG for which data should be pulled (can be one of "Baseline (first observation of the year)", "Mid-year (middle of service, if applicable)", "End of year (last observation of the year)", "Other", or "Ongoing")

Value

a ggplot


FSOT IPG Chart Summary Maker

Description

Creates a chart to summarise the FSOT IPG based on the round selected

Usage

make_ipg_fsot_summary_chart(
  data,
  round = "Baseline (first observation of the year)"
)

Arguments

data

the data

round

the round of the IPG for which data should be pulled (can be one of "Baseline (first observation of the year)", "Mid-year (middle of service, if applicable)", "End of year (last observation of the year)", "Other", or "Ongoing")

Value

a ggplot


Math IPG Chart Summary Maker

Description

Creates a chart to summarise the Math IPG based on the round selected

Usage

make_ipg_math_summary_chart(
  data,
  round = "Baseline (first observation of the year)"
)

Arguments

data

the data

round

the round of the IPG for which data should be pulled (can be one of "Baseline (first observation of the year)", "Mid-year (middle of service, if applicable)", "End of year (last observation of the year)", "Other", or "Ongoing")

Value

a ggplot


Student Work Circle Charts

Description

Chart to show the

Usage

make_student_work_chart_circle(data)

Arguments

data

the data for the plotter to use, should include all columns of interest

Value

a ggplot


Student Work People Chart

Description

Chart to show the

Usage

make_student_work_chart_people(data)

Arguments

data

the data for the plotter to use, should include all columns of interest

Value

a ggplot


Teacher Curriculum Perceptions Graph

Description

Creates a chart to summarise the teacher perceptions of curriculum

Usage

make_teacher_curriculum_perceptions(data)

Arguments

data

the data

Value

a ggplot


Teacher Curriculum Usage Graph

Description

Creates a chart to summarise the Teacher Curriculum Usage from the Educator Survey

Usage

make_teacher_curriculum_usage(data)

Arguments

data

the data

Value

a ggplot


Teacher Use of Lessons Graph

Description

Creates a chart to summarise the teacher use of lessons from district or school-adopted materials

Usage

make_teacher_lesson_usage(data)

Arguments

data

the data

Value

a ggplot


Teacher Perceptions Peer Relationships Graph

Description

Creates a chart to summarise the teacher perceptions of of peer relationships

Usage

make_teacher_perceptions_peer_relationships(data)

Arguments

data

the data

Value

a ggplot


Teacher School Leader Perceptions Graph

Description

Creates a chart to summarise the teacher perceptions of school leaders

Usage

make_teacher_perceptions_school_leaders(data)

Arguments

data

the data

Value

a ggplot


A list of NA type words to ignore in qualitative responses

Description

A list of NA type words to ignore in qualitative responses

Usage

na_df

Format

A character vector


Negative Conditional Filter

Description

Conditionally filters value given that it is not the first parameter, for use in shiny apps

Usage

neg_cond_filter(data, if_not_this, filter_this, dat_filter)

Arguments

data

the dataframe to apply filter

if_not_this

If value is not this

filter_this

Filter for this

dat_filter

Data column object to filter

Value

filtered dataframe


No Data Plot

Description

A plot that says no data available yet this year

Usage

no_data_plot_currently

Format

An object of class gg (inherits from ggplot) of length 11.


No Data Plot Adjustable Title

Description

A plot that says no data available by default, but can be adjusted to say whatever you want

Usage

no_data_plot_custom(title = "No data available!")

No Data Plot

Description

A plot that says no data available, and to check your filters

Usage

no_data_plot_filters

Format

An object of class gg (inherits from ggplot) of length 11.


Find elements x not in a vector y

Description

Find elements x not in a vector y

Usage

x %!in% y

Arguments

x

A vector of what shouldn't exist

y

A vector to check against

Value

Returns elements not in vector


Ongoing Coaching feedback graph dependent on race and content area

Description

Returns a barchart for selections in the relevant questions of the end of coaching survey

Usage

ongoing_coaching_feedback_graph(data)

Arguments

data

the data to use

Value

prints a ggplot object


Quote Visualization

Description

takes a dataframe and makes a gt table or ggplot that shows a quote

Usage

quote_viz(
  data,
  text_col = colnames(data)[1],
  viz_type = "gt",
  custom_highlight = NULL,
  n = 3,
  print = T,
  width = 60,
  title = NULL,
  suppress_warnings = T,
  align = "center",
  save = T,
  ...
)

Arguments

data

the dataframe

text_col

columns to create table for

viz_type

ggplot or gt visualization

custom_highlight

a vector, optional custom highlighting

n

integer, number of words to auto-highlight

print

T, whether or not to print the highlighted words to console

width

The width of the table generated

title

the title of the ggplot or gt

suppress_warnings

T/F suppression of warnings

align

the table alignment: "left", "center", "right"

...

Arguments passed onto the gt table

Value

a ggplot/gt that visualizes text

Examples

## Not run: 
df <- tlShiny::survey_monkey
colnames(df)[1] <- "What learning are you excited to try?"
quote_viz(
  data = df,
  text_col = "What learning are you excited to try?",
  viz_type = "gt",
  title = "Responses from Survey Monkey"
)

## End(Not run)

Remove Empty Rows

Description

Filters out all rows that contain entirely NA

Usage

remove_empty_tl(data)

Arguments

data

the dataframe to apply filter

Value

a dataframe with no empty rows


Discrete color & fill scales based on the Teaching Lab palette

Description

See tl_palette().

Usage

scale_colour_tl(n, color = "blue", ...)

scale_color_tl(n, color = "blue", ...)

scale_fill_tl(
  n,
  color = c("blue", "orange", "purple", "green", "teal", "tl_colors"),
  ...
)

Arguments

n

the number of colors

color

the color from tl_palette

...

Arguments passed on to ggplot2::discrete_scale

aesthetics

The names of the aesthetics that this scale works with.

scale_name

[Deprecated] The name of the scale that should be used for error messages associated with this scale.

palette

A palette function that when called with a single integer argument (the number of levels in the scale) returns the values that they should take (e.g., scales::pal_hue()).

name

The name of the scale. Used as the axis or legend title. If waiver(), the default, the name of the scale is taken from the first mapping used for that aesthetic. If NULL, the legend title will be omitted.

breaks

One of:

  • NULL for no breaks

  • waiver() for the default breaks (the scale limits)

  • A character vector of breaks

  • A function that takes the limits as input and returns breaks as output. Also accepts rlang lambda function notation.

labels

One of:

  • NULL for no labels

  • waiver() for the default labels computed by the transformation object

  • A character vector giving labels (must be same length as breaks)

  • An expression vector (must be the same length as breaks). See ?plotmath for details.

  • A function that takes the breaks as input and returns labels as output. Also accepts rlang lambda function notation.

limits

One of:

  • NULL to use the default scale values

  • A character vector that defines possible values of the scale and their order

  • A function that accepts the existing (automatic) values and returns new ones. Also accepts rlang lambda function notation.

na.translate

Unlike continuous scales, discrete scales can easily show missing values, and do so by default. If you want to remove missing values from a discrete scale, specify na.translate = FALSE.

na.value

If na.translate = TRUE, what aesthetic value should the missing values be displayed as? Does not apply to position scales where NA is always placed at the far right.

drop

Should unused factor levels be omitted from the scale? The default, TRUE, uses the levels that appear in the data; FALSE includes the levels in the factor. Please note that to display every level in a legend, the layer should use show.legend = TRUE.

guide

A function used to create a guide or its name. See guides() for more information.

call

The call used to construct the scale for reporting messages.

super

The super class to use for the constructed scale


End of session feedback graph dependent on race and content area

Description

Returns a barchart for selections in the relevant questions of the end of coaching survey

Usage

session_feedback_graph(data)

Arguments

data

the data to use

Value

prints a ggplot object


Calculate the square of a number

Description

This function computes the square of a numeric input.

Usage

square(x)

Arguments

x

A numeric input.

Value

The square of the input.

Examples

tlShiny::square(2)
tlShiny::square(3.5)

Various lexicons for English stop words

Description

English stop words from three lexicons, as a data frame. The snowball and SMART sets are pulled from the tm package. Note that words with non-ASCII characters have been removed.

Usage

stop_words

Format

A data frame with 1149 rows and 2 variables:

word

An English word

lexicon

The source of the stop word. Either "onix", "SMART", or "snowball"

Source


Student percent agree/strongly agree

Description

Automatically dodged bar chart for student data

Usage

student_bar_chart(
  data,
  col_select,
  agree_select,
  string_remove,
  title,
  legend_position = c(0.8, 0.25)
)

Arguments

data

the data for the plotter to use, should include all columns of interest

col_select

the columns to select with 'tidyselect::contains'

agree_select

the type of agree/strongly agree to select, for example also often/always

string_remove

NULL by default, provides an optional string removal

title

the title for the plot

legend_position

c(0.8, 0.25) by default, adjustable

Value

a ggplot object


The current subsites selection

Description

All Subsites as currently named in Qualtrics Reference Survey

Format

A vector of subsite names

Source

https://docs.google.com/spreadsheets/d/11jlo9UeWxZGwunhDb24hZBwAKc5b8ZKM9AYNWZaUyZY/edit#gid=243942212


A survey monkey text selection

Description

Survey monkey reviews from the course survey in response to the question What is the learning from this course that you are most excited about trying out?, as a data frame.

Usage

survey_monkey

Format

A data frame with 87 rows and 1 variable:

'What is the learning from this course that you are most excited about trying out?'

A deidentified review in each row

@source https://www.surveymonkey.com/r/TLendofcourse


Teaching Lab Custom Ggplot2 Theme

Description

Teaching Lab Custom Ggplot2 Theme

Usage

theme_tl(
  base_family = "Calibri",
  base_size = 14,
  strip_text_family = base_family,
  strip_text_size = 15,
  plot_title_family = "Calibri",
  plot_title_size = 20,
  plot_title_margin = 10,
  subtitle_family = "Roboto",
  subtitle_size = 15,
  subtitle_margin = 15,
  caption_family = "Roboto",
  caption_size = 11,
  caption_margin = 10,
  axis_title_family = "Calibri",
  axis_title_size = 12,
  axis_title_just = "mm",
  axis_text_size = 10.5,
  dark = FALSE,
  grid = TRUE,
  axis = FALSE,
  ticks = FALSE,
  markdown = FALSE,
  legend = F
)

Arguments

base_family

base font family

base_size

base font size

strip_text_family

facet label font family

strip_text_size

facet label text size

plot_title_family

plot title family

plot_title_size

plot title font size

plot_title_margin

plot title margin

subtitle_family

plot subtitle family

subtitle_size

plot subtitle size

subtitle_margin

plot subtitle margin

caption_family

plot caption family

caption_size

plot caption size

caption_margin

plot caption margin

axis_title_family

axis title font family

axis_title_size

axis title font size

axis_title_just

axis title font justification blmcrt

axis_text_size

axis text size

dark

dark mode TRUE, FALSE

grid

panel grid (TRUE, FALSE, or a combination of X, x, Y, y)

axis

axis TRUE, FALSE, [xy]

ticks

ticks TRUE, FALSE

markdown

enabled ggtext markdown styling TRUE, FALSE

legend

default no legend with F

Note

It requires installing Roboto, Calibri fonts unless you change the font parameters

https://www.google.com/fonts


TL Default Blue Palette

Description

TL Default Blue Palette

Usage

tl_pal_blue

Format

An object of class character of length 8.


Teaching Lab Color Palette Maker

Description

Teaching Lab Color Palette Maker

Usage

tl_palette(
  color = c("blue", "orange", "purple", "green", "teal", "tl_colors"),
  theme = c("dark"),
  n = 6,
  base_color_start = NULL
)

Arguments

color

the color palette to generate

theme

if theme is light or dark

n

number of colors to generate

base_color_start

the base color of the palette to start with, ramping towards the color option

Value

color ramp palette function


Teaching Lab Color Palette Maker

Description

Teaching Lab Color Palette Maker

Usage

tl_palette2(n = 6, base_color_start = NULL, end_color_start = NULL)

Arguments

n

number of colors to generate

base_color_start

the base color of the palette to start with, ramping from the color option

base_color_end

the base color of the palette to end with, ramping towards the color option

Value

color ramp palette function


Get the percent of a column that equals specific values

Description

Automatically scaled stacked bar chart with TL theming

Usage

tl_select_percent(data, percent_equal)

Arguments

data

the data for the plotter to use, should include all columns of interest

percent_equal

string inputs to find the percent of the column that equals those values

Value

a percentage as a string