Error In Xj[I] : Invalid Subscript Type ‘List’

Error In Xj[I] : Invalid Subscript Type ‘List’

I was recently working on a project that involved reading in data from a text file and then performing some calculations on it. I ran into an error that I had never seen before, and it took me a little while to figure out what was going on. The error was: “Error in xj[i] : invalid subscript type ‘list’.”

At first I thought that maybe my data was formatted incorrectly, but after double-checking I realized that wasn’t the case. So then I started to look into what the error message meant. Turns out, the error is caused when you try to subset a list using another list. For example, if you have a list of numbers, and you try to subset it using a list of indices, R will throw this error.

So in my case, I was trying to subset a list of data using a list of indices, which caused the error. The fix was simple, I just had to convert my list of indices into a vector. Once I did that, everything worked as expected.

If you ever run into this error, just remember that you need to use a vector to subset a list, not another list.

YOU MAY BE INTERESTED IN:  Rockford Middle School Supply List

Leave a Comment

Your email address will not be published.