Learn R Programming

MetaNLP (version 0.1.4)

write_csv: Save the document-term matrix

Description

This function can be used to save the document-term matrix of a MetaNLP object as a csv-file.

Usage

write_csv(object, ...)

# S4 method for MetaNLP write_csv(object, path, type = c("train", "test"), ...)

Value

nothing

Arguments

object

An object of class MetaNLP.

...

Additional arguments for write.table, e.g. encoding as UTF-8.

path

Path where to save the csv.

type

Specifies if the document-term matrix should be saved as "train_wcm.csv" or "test_wcm.csv". If the user wants to use another file name, the whole path including the file name should be given as the path argument

Details

If a path to a specific folder is given (but the path name does not end with ".csv"), the file is saved in this folder as "train_wcm.csv" or "test_wcm.csv". By providing a path ending with ".csv", the user can override the default naming convention and the file is saved according to this path.

Examples

Run this code
path <- system.file("extdata", "test_data.csv", package = "MetaNLP", mustWork = TRUE)
obj <- MetaNLP(path)
obj2 <- delete_stop_words(obj)
write_path <- tempdir()
write_csv(obj2, path = write_path)
file.remove(file.path(write_path, "train_wcm.csv"))

Run the code above in your browser using DataLab