Error in Xj[I]: Invalid Subscript Type 'List'

Error: invalid subscript type 'list' in R

We need to use concatenate to create a vector instead of list

x <- c("alpha", "beta")
rowSums(d[x])
#[1] 5 7 9

and if we are using list, then unlist it to create a vector as data.frame takes a vector of column names (column index) or row names (row index) to subset the columns or rows

x <- list("alpha", "beta")
rowSums(d[unlist(x)])
#[1] 5 7 9

Error in x[j] : invalid subscript type 'list' while using subset in R

you appear to have a problem with the type of object you have. you can try converting it to a data frame using unlist, as.data.frame(), etc.

Error in xj[i] : invalid subscript type 'list' when do LDA in R

subset wants a vector and you give him a data frame (i.e. a list). Do

lda(flag ~ spent + realpurchase_cash, mydat, subset=index)

or, since train is already your desired subset, just

lda(flag ~ spent + realpurchase_cash, data=train)


Related Topics



Leave a reply



Submit