as.text.table: Convert a data.table column of character vectors into a...

Description Usage Arguments Value Examples

View source: R/text.table.R

Description

Convert a data.table column of character vectors into a column with one row per word grouped by a grouping column. Optionally will split a column of strings into vectors of constituents.

Usage

1
as.text.table(x, text, split = NULL, group_by = NULL)

Arguments

x

A data.table.

text

A string, the name of the column in x containing text to un-nest.

split

A string with a pattern to split the text in text column into constituent parts.

group_by

A vector of column names to group by. Doesn't work if the group by column is a list column.

Value

A data.table, text column un-nested to one row per word.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
as.text.table(
  x = as.data.table(
    list(
      col1 = c(
        "a",
        "b"
      ),
      col2 = c(
        tolower("The dog is nice because it picked up the newspaper."),
        tolower("The dog is extremely nice because it does the dishes.")
      )
    )
  ),
  text = "col2",
  split = " "
)

textTools documentation built on Feb. 5, 2021, 5:07 p.m.