In my function below, from time to time (please run a few times to see), I get an error message from inside the data.frame
that says x
and y
differ by 2 rows.
I was wondering how this occasional error could be fixed?
x = rnorm(1e2)
h = hist(x = x, plot = F)
DF = data.frame(
x = unlist(sapply(1:length(h$mids), function(i) rep(h$mids[i], each = h$counts[i]))),
y = unlist(sapply(h$counts, function(c) 1:c)))
plot(DF$x, DF$y)
Error in data.frame(x = unlist(sapply(1:length(h$mids), function(i) rep(h$mids[i], :
arguments imply differing number of rows: 100, 102