MrJman006
MrJman006

Reputation: 770

Histogram ylim in R

I have a data set of ages that I am trying to set up in a histogram chart, but my y axis looks really wrong. The command I am using is hist(Data$age, main="Distribution of Age", xlab="Age Brackets", ylab="Absolute Frequency", breaks=10, prob=T)

I tried ylim=c(1, 15) as 1 is my lowest frequency and 15 is my largest, but the axies show up correctly, but then the bars don't show up anymore.

Also is there some documentation repository that would help with the research on these kind of things?

Upvotes: 1

Views: 9165

Answers (2)

Johan Larsson
Johan Larsson

Reputation: 3694

Setting prob = T (TRUE) mean that you get probabilities on the y axis, which are in [0, 1], so setting ylim = c(1, 15) would exclude basically all the data. Either adjust ylim or set prob = FALSE.

Upvotes: 0

pmagunia
pmagunia

Reputation: 1788

You can try hist(Data[,2]) or something similar. Just change the 2 to reference the correct column of the dataset. Your syntax looks OK. Try

help("hist")

for the histogram help topic.

Upvotes: 2

Related Questions