Colonel Panic
Colonel Panic

Reputation: 137732

R plot frequency distribution

How can I plot a frequency distribution in R? I don't want to bin values. I just want to plot frequency for each value. The hist function insists on binning values unless I specify bins manually (really tedious, because I don't know the values in advance).

Upvotes: 2

Views: 10121

Answers (3)

FMZ
FMZ

Reputation: 206

table(sample(1:10,20,replace=T))

Upvotes: 1

cianius
cianius

Reputation: 2412

have you tried s.distri {ade4}? http://pbil.univ-lyon1.fr/ade4/ade4-html/s.distri.html

 library(ade4)
  xy <- cbind.data.frame(x = runif(200,-1,1), y = runif(200,-1,1))
  distri <- data.frame(w1 = rpois(200, xy$x * (xy$x > 0)))
  s.value(xy, distri$w1, cpoi = 1)

Upvotes: 1

BenBarnes
BenBarnes

Reputation: 19454

You could plot the table of your data:

xx<-sample(1:10,100,replace=TRUE)
plot(table(xx))

a histogram

Upvotes: 7

Related Questions