From 032b12f9d356e382e3b718c445ea0325e757dc9f Mon Sep 17 00:00:00 2001 From: trinker Date: Wed, 30 Jul 2014 22:12:07 -0400 Subject: [PATCH] Checked documentation examples in prep for next push to CRAN. close #195 --- R/as.tdm.R | 4 ++-- R/cm_time2long.R | 2 +- R/discourse_map.R | 4 ++-- R/formality.R | 2 +- R/pronoun_type.R | 10 +++++----- R/sentSplit.R | 22 +++++++++++++--------- R/synonyms.R | 11 ++++++++--- man/as.tdm.Rd | 4 ++-- man/cm_time2long.Rd | 2 +- man/discourse_map.Rd | 4 ++-- man/formality.Rd | 2 +- man/pronoun_type.Rd | 10 +++++----- man/sentSplit.Rd | 5 ++++- man/synonyms.Rd | 4 ++-- 14 files changed, 49 insertions(+), 37 deletions(-) diff --git a/R/as.tdm.R b/R/as.tdm.R index 8b0f54d4..ce211805 100644 --- a/R/as.tdm.R +++ b/R/as.tdm.R @@ -66,7 +66,7 @@ #' speech <- stemmer(dat$dialogue) #' mytable1 <- with(dat, as.tdm(speech, list(person, time), stopwords = Top25Words)) #' -#' fit <- ca(mytable1) +#' fit <- ca(as.matrix(ytable1)) #' summary(fit) #' plot(fit) #' plot3d.ca(fit, labels=1) @@ -74,7 +74,7 @@ #' #' mytable2 <- with(dat, as.tdm(speech, list(person, time), stopwords = Top200Words)) #' -#' fit2 <- ca(mytable2) +#' fit2 <- ca(as.matrix(mytable2)) #' summary(fit2) #' plot(fit2) #' plot3d.ca(fit2, labels=1) diff --git a/R/cm_time2long.R b/R/cm_time2long.R index e15c301c..891b843c 100644 --- a/R/cm_time2long.R +++ b/R/cm_time2long.R @@ -52,7 +52,7 @@ #' ) #' #' ## General ldots Approach -#' cm_time2long(bar) +#' cm_time2long(bar1) #' cm_time2long(bar1, bar2, v.name="time") #' #' ## Specify `object` Approach diff --git a/R/discourse_map.R b/R/discourse_map.R index 974bb73e..3742cf80 100644 --- a/R/discourse_map.R +++ b/R/discourse_map.R @@ -130,7 +130,7 @@ #' library(animation) #' library(igraph) #' -#' loc <- folder(animation_dialogue) +#' loc <- reports::folder(animation_dialogue) #' ans <- Animate(test) #' #' ## Set up the plotting function @@ -164,7 +164,7 @@ #' ## More Elaborate Layout #' test2 <- with(mraja1, discourse_map(dialogue, person)) #' -#' loc2 <- folder(animation_dialogue2) +#' loc2 <- reports::folder(animation_dialogue2) #' ans2 <- Animate(test2) #' ## Set up the plotting function #' oopt <- animation::ani.options(interval = 0.1) diff --git a/R/formality.R b/R/formality.R index 511e0516..3fa22653 100644 --- a/R/formality.R +++ b/R/formality.R @@ -138,7 +138,7 @@ #' form_bar <- Animate(form_ani2, as.network=FALSE) #' #' ## Generate a folder -#' loc <- folder(animation_formality) +#' loc <- reports::folder(animation_formality) #' #' ## Set up the plotting function #' oopt <- animation::ani.options(interval = 0.1) diff --git a/R/pronoun_type.R b/R/pronoun_type.R index f177f146..edeb1890 100644 --- a/R/pronoun_type.R +++ b/R/pronoun_type.R @@ -37,13 +37,13 @@ #' \code{\link[qdap]{subject_pronoun_type}} #' @export #' @references -#' Fairclough, N. (1989). Language and Power. London: Longman. \cr +#' Fairclough, N. (1989). Language and power. London: Longman. \cr #' -#' Fairclough, N. (2003). Analysing Discourse: Textual Analysis for Social -#' Research. Oxford and New York: Routledge.\cr +#' Fairclough, N. (2003). Analysing discourse: Textual analysis for social +#' research. Oxford and New York: Routledge.\cr #' -#' Okamura, A. (2009). Use of Personal Pronouns In Two Types of Monologic -#' Academic Speech. The Economic Journal of Takasaki City University of +#' Okamura, A. (2009). Use of personal pronouns in two types of monologic +#' academic speech. The Economic Journal of Takasaki City University of #' Economics, 52(1). 17-26. \cr #' #' Us and them: Social categorization and the process of intergroup bias. diff --git a/R/sentSplit.R b/R/sentSplit.R index d3f31a1d..ae31fe44 100644 --- a/R/sentSplit.R +++ b/R/sentSplit.R @@ -17,6 +17,8 @@ #' @param text.place A character string giving placement location of the text #' column. This must be one of the strings \code{"original"}, \code{"right"} or #' \code{"left"}. +#' @param verbose logical. If \code{TRUE} select diagnostics from +#' \code{\link[qdap]{check_text}} are reported. #' @param \ldots Additional options passed to \code{\link[qdap]{stem2df}}. #' @param grouping.var The grouping variables. Default \code{NULL} generates #' one word list for all text. Also takes a single grouping variable or a list @@ -81,16 +83,18 @@ sentSplit <- function(dataframe, text.var, rm.var = NULL, endmarks = c("?", ".", "!", "|"), incomplete.sub = TRUE, rm.bracket = TRUE, stem.col = FALSE, - text.place = "right", ...) { + text.place = "right", verbose = is.global(2), ...) { - checks <- check_text(dataframe[[text.var]]) - checks <- checks[!names(checks) %in% c("double_punctuation", - "missing_value", "potentially_misspelled")] - pot_probs <- !sapply(checks, is.null) - if(sum(pot_probs) > 0) { - probs <- gsub("_", " ", paste(names(pot_probs)[pot_probs], collapse=", ")) - warning("The following problems were detected:\n", probs, - "\n\n*Consider running `check_text`") + if (verbose) { + checks <- check_text(dataframe[[text.var]]) + checks <- checks[!names(checks) %in% c("double_punctuation", + "missing_value", "potentially_misspelled")] + pot_probs <- !sapply(checks, is.null) + if(sum(pot_probs) > 0) { + probs <- gsub("_", " ", paste(names(pot_probs)[pot_probs], collapse=", ")) + warning("The following problems were detected:\n", probs, + "\n\n*Consider running `check_text`") + } } if (is.null(rm.var)) { diff --git a/R/synonyms.R b/R/synonyms.R index bd2c4d9d..64c96516 100644 --- a/R/synonyms.R +++ b/R/synonyms.R @@ -39,7 +39,7 @@ #' synonyms_frame(syn_dat) #' syn(c("R", "show"), synonym.frame = syn_frame(syn_dat)) #' -#' syns.hash <- syn_frame(syn_dat, prior.frame = SYNONYM) +#' syns.hash <- syn_frame(syn_dat, prior.frame = qdapDictionaries::key.syn) #' syn(c("R", "show", "like", "robot"), synonym.frame = syns.hash) #' } synonyms <- function(terms, return.list = TRUE, @@ -92,12 +92,12 @@ syn <- synonyms #' #' @param synonym.list A named list of lists (or vectors) of synonyms. #' @param prior.frame A prior synonyms data.frame in the format produced by -#' \code{synonym_frame}. +#' \code{synonyms_frame}. #' @export #' @importFrom qdapTools list2df #' @rdname synonyms synonyms_frame <- function(synonym.list, prior.frame) { - + synonym.list <- lapply(synonym.list, function(x) { if(is.list(x)) { x @@ -110,7 +110,12 @@ synonyms_frame <- function(synonym.list, prior.frame) { phase3 <- list2df(lapply(phase2, paste, collapse = " @@@@ "), col2 = "word", col1 = "match.string")[2:1] phase3[] <- lapply(phase3, as.character) + if (!missing(prior.frame)) { + + class(prior.frame) <- "data.frame" + suppressWarnings(colnames(prior.frame) <- colnames(phase3)) + phase3 <- data.frame(rbind(phase3, prior.frame[!prior.frame[, "word"] %in% phase3[, "word"], ] ), stringsAsFactors = FALSE) diff --git a/man/as.tdm.Rd b/man/as.tdm.Rd index 99f55862..24ebcf97 100644 --- a/man/as.tdm.Rd +++ b/man/as.tdm.Rd @@ -281,7 +281,7 @@ dat <- dat[dat$person \%in\% qcv(ROMNEY, OBAMA), ] speech <- stemmer(dat$dialogue) mytable1 <- with(dat, as.tdm(speech, list(person, time), stopwords = Top25Words)) -fit <- ca(mytable1) +fit <- ca(as.matrix(ytable1)) summary(fit) plot(fit) plot3d.ca(fit, labels=1) @@ -289,7 +289,7 @@ plot3d.ca(fit, labels=1) mytable2 <- with(dat, as.tdm(speech, list(person, time), stopwords = Top200Words)) -fit2 <- ca(mytable2) +fit2 <- ca(as.matrix(mytable2)) summary(fit2) plot(fit2) plot3d.ca(fit2, labels=1) diff --git a/man/cm_time2long.Rd b/man/cm_time2long.Rd index 29b34266..e66e6789 100644 --- a/man/cm_time2long.Rd +++ b/man/cm_time2long.Rd @@ -59,7 +59,7 @@ bar2 <- list( ) ## General ldots Approach -cm_time2long(bar) +cm_time2long(bar1) cm_time2long(bar1, bar2, v.name="time") ## Specify `object` Approach diff --git a/man/discourse_map.Rd b/man/discourse_map.Rd index 7362404a..b2f4d439 100644 --- a/man/discourse_map.Rd +++ b/man/discourse_map.Rd @@ -145,7 +145,7 @@ dev.off() library(animation) library(igraph) -loc <- folder(animation_dialogue) +loc <- reports::folder(animation_dialogue) ans <- Animate(test) ## Set up the plotting function @@ -179,7 +179,7 @@ saveHTML(FUN(), autoplay = FALSE, loop = TRUE, verbose = FALSE, ## More Elaborate Layout test2 <- with(mraja1, discourse_map(dialogue, person)) -loc2 <- folder(animation_dialogue2) +loc2 <- reports::folder(animation_dialogue2) ans2 <- Animate(test2) ## Set up the plotting function oopt <- animation::ani.options(interval = 0.1) diff --git a/man/formality.Rd b/man/formality.Rd index 731fa192..b810af75 100644 --- a/man/formality.Rd +++ b/man/formality.Rd @@ -151,7 +151,7 @@ bgb <- edge_apply(bgb, label.color="yellow") form_bar <- Animate(form_ani2, as.network=FALSE) ## Generate a folder -loc <- folder(animation_formality) +loc <- reports::folder(animation_formality) ## Set up the plotting function oopt <- animation::ani.options(interval = 0.1) diff --git a/man/pronoun_type.Rd b/man/pronoun_type.Rd index 1148f9ad..f4557e27 100644 --- a/man/pronoun_type.Rd +++ b/man/pronoun_type.Rd @@ -71,13 +71,13 @@ plot(out2, 3, ncol=7) } } \references{ -Fairclough, N. (1989). Language and Power. London: Longman. \cr +Fairclough, N. (1989). Language and power. London: Longman. \cr -Fairclough, N. (2003). Analysing Discourse: Textual Analysis for Social -Research. Oxford and New York: Routledge.\cr +Fairclough, N. (2003). Analysing discourse: Textual analysis for social +research. Oxford and New York: Routledge.\cr -Okamura, A. (2009). Use of Personal Pronouns In Two Types of Monologic -Academic Speech. The Economic Journal of Takasaki City University of +Okamura, A. (2009). Use of personal pronouns in two types of monologic +academic speech. The Economic Journal of Takasaki City University of Economics, 52(1). 17-26. \cr Us and them: Social categorization and the process of intergroup bias. diff --git a/man/sentSplit.Rd b/man/sentSplit.Rd index df0c98b0..6bc9c3ea 100644 --- a/man/sentSplit.Rd +++ b/man/sentSplit.Rd @@ -8,7 +8,7 @@ \usage{ sentSplit(dataframe, text.var, rm.var = NULL, endmarks = c("?", ".", "!", "|"), incomplete.sub = TRUE, rm.bracket = TRUE, stem.col = FALSE, - text.place = "right", ...) + text.place = "right", verbose = is.global(2), ...) sentCombine(text.var, grouping.var = NULL, as.list = FALSE) @@ -39,6 +39,9 @@ and replaces with \code{"|"}.} column. This must be one of the strings \code{"original"}, \code{"right"} or \code{"left"}.} +\item{verbose}{logical. If \code{TRUE} select diagnostics from +\code{\link[qdap]{check_text}} are reported.} + \item{\ldots}{Additional options passed to \code{\link[qdap]{stem2df}}.} \item{grouping.var}{The grouping variables. Default \code{NULL} generates diff --git a/man/synonyms.Rd b/man/synonyms.Rd index 9e1273dc..73d71ba5 100644 --- a/man/synonyms.Rd +++ b/man/synonyms.Rd @@ -34,7 +34,7 @@ was found at the head of the output.} \item{synonym.list}{A named list of lists (or vectors) of synonyms.} \item{prior.frame}{A prior synonyms data.frame in the format produced by -\code{synonym_frame}.} +\code{synonyms_frame}.} } \value{ Returns a list of vectors or vector of possible words that match @@ -64,7 +64,7 @@ syn_dat <- list( synonyms_frame(syn_dat) syn(c("R", "show"), synonym.frame = syn_frame(syn_dat)) -syns.hash <- syn_frame(syn_dat, prior.frame = SYNONYM) +syns.hash <- syn_frame(syn_dat, prior.frame = qdapDictionaries::key.syn) syn(c("R", "show", "like", "robot"), synonym.frame = syns.hash) } }