This is a bit of a shot in the dark, but I have a script that does exactly what I expect it to do, yet, at the very end of the script I get an error like this:
Error in `[<-.data.frame`(`*tmp*`, "label", val开发者_运维问答ue = c(1L, 0L)) :
replacement has 2 rows, data has 0
In terms of an answer, I'm looking for general suggestions on how to track errors like this in R, best practices for using loops and double checking that they "made it through".
Any thoughts, suggestions, or past experiences that could relegate or inform an error message like this?
I already included my comments about debugging practices in this related question. But regarding the specific message that you show here: that means that you're trying to write out 2 rows to some dataset that has 0 rows. Something like this:
x <- data.frame(y=NULL)
x$y <- 1:2
精彩评论