소스 검색

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)) {


불러오는 중...
취소
저장