Learn R Programming

SentimentAnalysis (version 1.3-5)

write: Write dictionary to text file

Description

This routine exports a sentiment dictionary to a text file which can be the source for additional problems or controlling the output.

Usage

write(d, file)

# S3 method for SentimentDictionaryWordlist write(d, file)

# S3 method for SentimentDictionaryBinary write(d, file)

# S3 method for SentimentDictionaryWeighted write(d, file)

Arguments

d

Dictionary of type SentimentDictionaryWordlist, SentimentDictionaryBinary or SentimentDictionaryWeighted

file

File to which the dictionary should be exported

See Also

read for later access

Examples

Run this code
d.out <- SentimentDictionary(c("uncertain", "possible", "likely"))
write(d.out, "example.dict")
d.in <- read("example.dict")
print(d.in)

d.out <- SentimentDictionary(c("increase", "rise", "more"),
                             c("fall", "drop"))
write(d.out, "example.dict")
d.in <- read("example.dict")
print(d.in)

d.out <- SentimentDictionary(c("increase", "decrease", "exit"),
                             c(+1, -1, -10),
                             rep(NA, 3),
                             intercept=5)
write(d.out, "example.dict")
d.in <- read("example.dict")
print(d.in)

unlink("example.dict")

Run the code above in your browser using DataLab