Strange error when replacing values in list

countypop$pop_2015[2044:2131] <- chosen_dataset[,chosen_index]
print(length(chosen_dataset[,chosen_index]))

This is the code I have. I'm replacing the section of data in countypop$pop_2015 with the values in chosen_dataset[,chosen_index]. However, this gives the error:

Error in <-: replacement has length zero

Yet the print statement prints 88, as desired. The entire program runs fine. Where is this error coming from?

Can you post the output of

dput(countypop$pop_2015[2044:2131])

and

dput(chosen_dataset[,chosen_index])

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.