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
Spread with Duplicate Identifiers for Rows
Tiff Plot Generation and Compression: R VS. Gimp VS. Irfanview VS. Photoshop File Sizes
Linear Regression with Constraints on The Coefficients
Using Read.Csv.Sql to Select Multiple Values from a Single Column
How to Predict Survival Probabilities in R
R: How to Prompt The User for Input from The Console
Strange Behaviour Dropping Column from Data.Frame in R
Change Plot Panel in Multipanel Plot in R
Is Ifelse Ever Appropriate in a Non-Vectorized Situation and Vice-Versa
Using Anonymous Functions with Summarize_Each or Mutate_Each
R Leaflet Offline Tiles Within Shiny
Generating Split-Color Rectangles from Ggplot2 Geom_Raster()
How to Fix Axis Margin with Ggplot2
R Finding Duplicates in One Column and Collapsing in a Second Column
How to Define a Function in Dplyr
Using If Else on a Dataframe Across Multiple Columns