Преглед на файлове

add additional parameter checks for analyze methods

genderequality-alternative
flavis преди 4 години
родител
ревизия
c80ec6259e
променени са 1 файла, в които са добавени 9 реда и са изтрити 1 реда
  1. +9
    -1
      R/analyze.R

+ 9
- 1
R/analyze.R Целия файл

@@ -8,6 +8,7 @@
#' @export
find_word <- function(res, word) {
is_valid_res(res)
stopifnot("word must be of type character" = is.character(word))
talks <- res$talks
mutate(
talks,
@@ -25,11 +26,15 @@ find_word <- function(res, word) {
#' @param fraction_only if TRUE, only select fraction from the resulting joined tibble
#'
#' left join speaker information from res$speaker into tb.
#' if fraction_only
#' if fraction_only, drop all columns but fraction
#'
#' @export
join_speaker <- function(tb, res, fraction_only = F) {
is_valid_res(res)
stopifnot("fraction_only must be of type logical" = is.logical(fraction_only))
stopifnot("tb must be a tibble" = inherits(tb, "tbl"))
stopifnot("tb must have a speaker column" = "speaker" %in% names(tb))

joined <- left_join(tb, res$speaker, by=c("speaker" = "id"))
if (fraction_only) select(joined, "fraction")
else joined
@@ -160,6 +165,9 @@ bar_plot_fractions <- function(tb,
#' @export
word_usage_by_date <- function(res, patterns, tidy=F) {
is_valid_res(res)
stopifnot("patterns must be of type character" = is.character(patterns))
stopifnot("tidy must be of type logical" = is.logical(tidy))

tb <- res$talks
nms <- names(patterns)
for (i in seq_along(patterns)) {


Loading…
Отказ
Запис