I was trying to create a new dataset by populating it with a for loop, per this answer. That is the for loop below:
sets = lapply(seq(-97, 99, by = 2), function(x) {
nums[[1]] = x
nums
})
stats = matrix(ncol=3, nrow=99)
for(i in 1:99) {
stats[i] = c(
sets[i[1]],
mean(sets[i]),
median(sets[i])
)
}
Runtime error:
argument is not numeric or logical: returning NAError in
sort.int(x, na.last = na.last, decreasing = decreasing, ...) :
'x' must be atomic
I don't even have a variable named x in the for loop, and I am not trying to sort anything. I jut want to calculate the three values and add them to a row in the dataframe. A similar question was asked here, but the poster was trying to sort something. What could be causing this error?
There was originally a , in stats[i]
as in stats[i,]
. I removed that but that did not fix the problem.