tf2doc: Transform Terms and Frequencies into a Text

Description Usage Arguments Value Examples

View source: R/tf2doc.R

Description

This function is simply a wrapper of rep, but allows different structures of input. For rewriting more texts in the same time, see m2doc.

Usage

1
tf2doc(term, num)

Arguments

term

terms that you want to rewrite into a text. A character vector is preferred, but matrix, list, data frame are also OK. NA in the argument will be taken as letters "NA" and repeated.

num

frequencies of terms in term. A numeric vector is preferred, but matrix, list, data frame are also OK. Its length must be equal to that of term. No NA is allowed.

Value

a character vector. Terms are pasted with a space.

Examples

1
2
3
x <- matrix(c("coffee", "milk", "tea", "cola"), nrow = 2)
y <- factor(c(5:8))
tf2doc(x, y)

chinese.misc documentation built on Sept. 13, 2020, 5:13 p.m.