NNS.term.matrix: NNS Term Matrix

Description Usage Arguments Value References Examples

View source: R/NNS_term_matrix.R

Description

Generates a term matrix for text classification use in NNS.reg.

Usage

1

Arguments

x

Text A two column dataset should be used. Concatenate text from original sources to comply with format. Also note the possiblity of factors in "DV", so "as.numeric(as.character(...))" is used to avoid issues.

oos

Out-of-sample text dataset to be classified.

names

Column names for "IV" and "oos". Defaults to FALSE.

Value

Returns the text as independent variables "IV" and the classification as the dependent variable "DV". Out-of-sample independent variables are returned with "OOS".

References

Viole, F. and Nawrocki, D. (2013) "Nonlinear Nonparametric Statistics: Using Partial Moments" http://amzn.com/1490523995

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
x <- data.frame(cbind(c("sunny", "rainy"), c(1, -1)))
NNS.term.matrix(x)

### Concatenate Text with space seperator, cbind with "DV"
x <- data.frame(cbind(c("sunny", "rainy"), c("windy", "cloudy"), c(1, -1)))
x <- data.frame(cbind(paste(x[ , 1], x[ , 2], sep = " "), as.numeric(as.character(x[ , 3]))))
NNS.term.matrix(x)


### NYT Example
## Not run: 
require(RTextTools)
data(NYTimes)

### Concatenate Columns 3 and 4 containing text, with column 5 as DV
NYT=data.frame(cbind(paste(NYTimes[ , 3], NYTimes[ , 4], sep = " "),
                     as.numeric(as.character(NYTimes[ , 5]))))
NNS.term.matrix(NYT)
## End(Not run)

NNS documentation built on May 15, 2018, 5:04 p.m.