Description Usage Arguments Value Examples
View source: R/mutate_counts.R
Apply normalization to a term count columns of termco
object without
stripping the class & attributes of the object.
1 | mutate_counts(x, fun = function(x) as.integer(x > 0))
|
x |
A |
fun |
A function to apply column-wise. |
... |
ignored. |
Returns a term_count
object.
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 | ## Not run:
library(dplyr)
term_list <- list(
`if` = c('if'),
ands = c('an'),
or = c('or'),
buts = c('but')
)
out <- presidential_debates_2012 %>%
with(term_count(dialogue, TRUE, term_list))
out
## default one-hot encoding
out %>%
mutate_counts()
## min-max scaling
out %>%
mutate_counts(function(x) (x - min(x)) / ((max(x) - min(x))))
## token counts
token_list <- list(
person = c('sam', 'i'),
place = c('here', 'house'),
thing = c('boat', 'fox', 'rain', 'mouse', 'box', 'eggs', 'ham'),
no_like = c('not like')
)
out2 <- token_count(sam_i_am, grouping.var = TRUE, token.list = token_list)
## default one-hot encoding
out2 %>%
mutate_counts()
## min-max scaling
out2 %>%
mutate_counts(function(x) (x - min(x)) / ((max(x) - min(x))))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.