Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206235

converting histogram bars to symbols in R

$
0
0

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


Viewing all articles
Browse latest Browse all 206235

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>