Description Usage Arguments Value Warning Note See Also Examples
termco
- Search a transcript by any number of
grouping variables for categories (themes) of grouped
root terms. While there are other termco functions in
the termco family (e.g. termco.d
)
termco
is a more powerful and flexible wrapper
intended for general use.
termco.d
- Search a transcript by any number of
grouping variables for root terms.
term.match
- Search a transcript for words that
exactly match term(s).
termco2mat
- Convert a termco dataframe to a
matrix for use with visualization functions (e.g.
heatmap2 of the gplots package).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | termco(text.var, grouping.var = NULL, match.list,
short.term = TRUE, ignore.case = TRUE, elim.old = TRUE,
percent = TRUE, digits = 2, apostrophe.remove = FALSE,
char.keep = NULL, digit.remove = NULL,
zero.replace = 0, ...)
termco.d(text.var, grouping.var = NULL, match.string,
short.term = FALSE, ignore.case = TRUE,
zero.replace = 0, percent = TRUE, digits = 2,
apostrophe.remove = FALSE, char.keep = NULL,
digit.remove = TRUE, ...)
term.match(text.var, terms, return.list = TRUE,
apostrophe.remove = FALSE)
termco2mat(dataframe, drop.wc = TRUE, short.term = TRUE,
rm.zerocol = FALSE, no.quote = TRUE, transform = TRUE,
trim.terms = TRUE)
|
text.var |
The text variable. |
grouping.var |
The grouping variables. Default NULL generates one word list for all text. Also takes a single grouping variable or a list of 1 or more grouping variables. |
match.list |
A list of named character vectors. |
short.term |
logical. If TRUE column names are trimmed versions of the match list, otherwise the terms are wrapped with 'term(phrase)' |
ignore.case |
logical. If TRUE case is ignored. |
elim.old |
logical. If TRUE eliminates the columns that are combined together by the named match.list. |
percent |
logical. If TRUE output given as percent. If FALSE the output is proportion. |
digits |
Integer; number of decimal places to round when printing. |
apostrophe.remove |
logical. If TRUE removes apostrophes from the text before examining. |
char.keep |
A character vector of symbol character
(i.e. punctuation) that strip should keep. The default
is to strip everything except apostrophes.
|
digit.remove |
logical. If TRUE strips digits from
the text before counting. |
zero.replace |
Value to replace 0 values with. |
... |
Other argument supplied to strip. |
match.string |
A vector of terms to search for.
When using inside of |
terms |
The terms to search for in the
|
return.list |
logical. If TRUE returns the output for multiple terms as a list by term rather than a vector. |
dataframe |
A termco (or termco.d) dataframe or object. |
drop.wc |
logical. If TRUE the word count column will be dropped. |
rm.zerocol |
logical. If TRUE any column containing all zeros will be removed from the matrix. |
no.quote |
logical. If TRUE the matrix will be printed without quotes if it's character. |
transform |
logical. If TRUE the matrix will be transformed. |
trim.terms |
logical. If TRUE trims the column header/names to ensure there is not a problem with spacing when using in other R functions. |
termco
& termco.d
- both return a list, of
class "termco.d", of data frames and information
regarding word counts:
raw |
raw word counts by grouping variable |
prop |
proportional word counts by grouping variable; proportional to each individual's word use |
rnp |
a character combination data frame of raw and proportional |
zero_replace |
value to replace zeros with; mostly internal use |
percent |
The value of percent used for plotting purposes. |
digits |
integer value of number of digits to display; mostly internal use |
term.match
- returns a list or vector of possible
words that match term(s).
termco2mat
- returns a matrix of term counts.
Percentages are calculated as a ratio of counts of
match.list
elements to word counts. Word counts
do not contain symbols or digits. Using symbols, digits
or small segments of full words (e.g. "to") could total
more than 100%.
The match.list/match.string is (optionally) case and character sensitive. Spacing is an important way to grab specific words and requires careful thought. Using "read" will find the words "bread", "read" "reading", and "ready". If you want to search for just the word "read" you'd supply a vector of c(" read ", " reads", " reading", " reader"). To search for non character arguments (i.e. numbers and symbols) additional arguments from strip must be passed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | #termco examples:
# General form for match.list
#
# ml <- list(
# cat1 = c(),
# cat2 = c(),
# catn = c()
# )
ml <- list(
cat1 = c(" the ", " a ", " an "),
cat2 = c(" I'" ),
"good",
the = c("the", " the ", " the", "the")
)
(dat <- with(raj.act.1, termco(dialogue, person, ml)))
names(dat)
dat$rnp #useful for presenting in tables
dat$raw #prop and raw are useful for performing calculations
dat$prop
datb <- with(raj.act.1, termco(dialogue, person, ml,
short.term = FALSE, elim.old=FALSE))
ltruncdf(datb, 20, 6)
(dat2 <- data.frame(dialogue=c("@bryan is bryan good @br",
"indeed", "@ brian"), person=qcv(A, B, A)))
ml2 <- list(wrds=c("bryan", "indeed"), "@", bryan=c("bryan", "@ br", "@br"))
with(dat2, termco(dialogue, person, match.list=ml2))
with(dat2, termco(dialogue, person, match.list=ml2, percent = FALSE))
DATA$state[1] <- "12 4 rgfr r0ffrg0"
termco(DATA$state, DATA$person, '0', digit.remove=FALSE)
DATA <- qdap::DATA
#Using with term.match and exclude
exclude(term.match(DATA$state, qcv(th), FALSE), "truth")
termco(DATA$state, DATA$person, exclude(term.match(DATA$state, qcv(th),
FALSE), "truth"))
MTCH.LST <- exclude(term.match(DATA$state, qcv(th, i)), qcv(truth, stinks))
termco(DATA$state, DATA$person, MTCH.LST)
syns <- synonyms("doubt")
syns[1]
termco(DATA$state, DATA$person, unlist(syns[1]))
synonyms("doubt", FALSE)
termco(DATA$state, DATA$person, list(doubt = synonyms("doubt", FALSE)))
termco(DATA$state, DATA$person, syns)
#termco.d examples:
term.match(DATA$state, qcv(i, the))
termco.d(DATA$state, DATA$person, c(" the", " i'"))
termco.d(DATA$state, DATA$person, c(" the", " i'"), ignore.case=FALSE)
termco.d(DATA$state, DATA$person, c(" the ", " i'"))
# termco2mat example:
MTCH.LST <- exclude(term.match(DATA$state, qcv(a, i)), qcv(is, it, am, shall))
termco_obj <- termco(DATA$state, DATA$person, MTCH.LST)
termco2mat(termco_obj)
plot(termco_obj)
plot(termco_obj, label = TRUE)
plot(termco_obj, label = TRUE, text.color = "red")
plot(termco_obj, label = TRUE, text.color="red", lab.digits=3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.