Reputation: 180
I have the following script:
ng <- dat_c[,6:75]
names <- names(ng)
res <- list()
res_2o <-list
for (i in names) {
res[[i]] <-aggregate(formula(paste(i, "~ola")), data = dat_c, FUN = "quantile" )
res_2o[[i]] <- res[[i]][2,2]
}
It's a simple script to get the quantiles of a list of variables which names are stored in "names. The first part of the loop works perfectly. However when I try to just select the second row and second column of each element in the list with "res_2o" I get the following error:
Error in res_2o[[i]] <- res[[i]][2, 2] :
object of type 'builtin' is not subsettable
How can I solve this error? How can I just select the second row and column in each element of the list with the for loop?
Upvotes: 0
Views: 30
Reputation: 3412
Should be:
res_2o <-list()
You have to call list. Also, it's a bad idea to name a var names
.
Upvotes: 1