vendredi 3 février 2017

Newbie cbind invalid subscript type 'list' on data set

Completely new to R here, so I'm looking for guidance on what the error is.

I'm trying to implement Knn, although when trying to set my train data, I get the error:

invalid subscript type 'list'

Here's my code:

rm(list=ls())
library(class)

library(ISLR)

train = subset(Weekly, Year >= 1990)
test = subset(Weekly, Year >= 2009)
Weekly.Lag1 = Weekly[,c("Lag1")]
Weekly.Lag2 = Weekly[,c("Lag2")]

train.X <- cbind(Weekly.Lag1,Weekly.Lag2)[train,]

Any suggestions are appreciated!

Aucun commentaire:

Enregistrer un commentaire