If I have a vector (e.g., v<-runif(1000)
), I can plot its histogram (which will look, more or less, as a horizontal line because v
is a sample f
Package plotrix has a function weighted.hist
which does what you want:
w<-seq(1,1000)
v<-sort(runif(1000))
weighted.hist(v, w)
An alternative from the weights
package is wtd.hist()
w<-seq(1,1000)
v<-sort(runif(1000))
wtd.hist(x=v,weight=w)
library(ggplot2)
w <- seq(1,1000)
v <- sort(runif(1000))
foo <- data.frame(v, w)
ggplot(foo, aes(v, weight = w)) + geom_histogram()