Skip to contents

This function creates a data.frame with features based on a text vector

Usage

textFeats(text, auto = TRUE, contains = NA, prc = FALSE)

Arguments

text

Character vector

auto

Boolean. Auto create some useful parameters?

contains

Character vector. Which columns do you wish to add with a contains (counter) string validator?

prc

Boolean. Also add percentage of each column compared with length?

Value

data.frame with additional features based on text.

Examples

textFeats("Bernardo Lares")
#> # A tibble: 1 × 12
#>   text     length  ncap  nvoc nexcl nquest  nats npunct  ndig nword nsymb nsmile
#>   <chr>     <int> <int> <int> <int>  <int> <int>  <int> <int> <dbl> <int>  <int>
#> 1 Bernard…     14     2     5     0      0     0      0     0     2     0      0
textFeats("Bernardo Lares 123!", prc = TRUE)
#> # A tibble: 1 × 23
#>   text     length  ncap  nvoc nexcl nquest  nats npunct  ndig nword nsymb nsmile
#>   <chr>     <int> <int> <int> <int>  <int> <int>  <int> <int> <dbl> <int>  <int>
#> 1 Bernard…     19     2     5     1      0     0      1     3     3     0      0
#> # ℹ 11 more variables: length_pct <dbl>, ncap_pct <dbl>, nvoc_pct <dbl>,
#> #   nexcl_pct <dbl>, nquest_pct <dbl>, nats_pct <dbl>, npunct_pct <dbl>,
#> #   ndig_pct <dbl>, nword_pct <dbl>, nsymb_pct <dbl>, nsmile_pct <dbl>
textFeats("I'm 100% Lares...", contains = c("Lares", "lares"))
#> # A tibble: 1 × 14
#>   text     length  ncap  nvoc nexcl nquest  nats npunct  ndig nword nsymb nsmile
#>   <chr>     <int> <int> <int> <int>  <int> <int>  <int> <int> <dbl> <int>  <int>
#> 1 I'm 100…     17     2     3     0      0     0      5     3     3     1      0
#> # ℹ 2 more variables: Lares <int>, lares <int>
textFeats(c("GREAT library!!", "Have you tried this 2?", "Happy faces :D :-)"))
#> # A tibble: 3 × 12
#>   text     length  ncap  nvoc nexcl nquest  nats npunct  ndig nword nsymb nsmile
#>   <chr>     <int> <int> <int> <int>  <int> <int>  <int> <int> <dbl> <int>  <int>
#> 1 GREAT l…     15     5     4     2      0     0      2     0     2     0      0
#> 2 Have yo…     22     1     7     0      1     0      1     1     5     0      0
#> 3 Happy f…     18     2     3     0      0     0      4     0     4     0      2