Skip to content

Commit

Permalink
Checked documentation examples in prep for next push to CRAN. close #195
Browse files Browse the repository at this point in the history
  • Loading branch information
trinker committed Jul 31, 2014
1 parent 734a305 commit 032b12f
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 37 deletions.
4 changes: 2 additions & 2 deletions R/as.tdm.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@
#' 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)
#'
#'
#' 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)
Expand Down
2 changes: 1 addition & 1 deletion R/cm_time2long.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#' )
#'
#' ## General ldots Approach
#' cm_time2long(bar)
#' cm_time2long(bar1)
#' cm_time2long(bar1, bar2, v.name="time")
#'
#' ## Specify `object` Approach
Expand Down
4 changes: 2 additions & 2 deletions R/discourse_map.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/formality.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions R/pronoun_type.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 13 additions & 9 deletions R/sentSplit.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)) {
Expand Down
11 changes: 8 additions & 3 deletions R/synonyms.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions man/as.tdm.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,15 @@ 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)


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)
Expand Down
2 changes: 1 addition & 1 deletion man/cm_time2long.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions man/discourse_map.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion man/formality.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions man/pronoun_type.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion man/sentSplit.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions man/synonyms.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 032b12f

Please sign in to comment.