Error in .subset(x, j) : invalid subscript type 'list'