as.text.table {textTools}R Documentation

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.

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

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

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 = " "
)

[Package textTools version 0.1.0 Index]