paste.data.frame: Concatenate text of each group of data together

View source: R/utils.R

paste.data.frameR Documentation

Concatenate text of each group of data together

Description

This function is similar to paste but works on a data.frame, hence paste.data.frame. It concatenates text belonging to groups of data together in one string. The function is the inverse operation of strsplit.data.frame.

Usage

paste.data.frame(data, term, group, collapse = " ")

Arguments

data

a data.frame or data.table

term

a string with a column name or a character vector of column names from data which you want to concatenate together using paste

group

a string with a column name or a character vector of column names from data indicating identifiers of groups. The text in term will be concatenated by group.

collapse

a character string that you want to use to collapse the text data together. Defaults to a single space.

Value

A data.frame with 1 row per group containing the columns from group and term where all the text in term for each group will be paste-d together, separated by the collapse argument.

See Also

strsplit.data.frame, paste

Examples

data(brussels_reviews_anno, package = "udpipe")
head(brussels_reviews_anno)
x <- paste.data.frame(brussels_reviews_anno, 
                      term = "lemma", 
                      group = c("doc_id", "sentence_id"))
str(x)
x <- paste.data.frame(brussels_reviews_anno, 
                      term = c("lemma", "token"), 
                      group = c("doc_id", "sentence_id"), 
                      collapse = "-")
str(x)                       

udpipe documentation built on Jan. 6, 2023, 5:06 p.m.