max's recipes

Histogram with "other" value at the end to show how many values were cut off

No votes yet

Sometimes you have to cut your histogram at some value but you want to still inform the reader how many values you cut off. Here I simply add one additional histogram bar at the right hand side, ">30", to display the missing values.

data(USArrests, "VADeaths")
data <- USArrests$Rape
h <- hist(data, breaks=seq(0,3000,1), plot=F)

subset <- h$counts[seq(1,limit)]
rest <- sum(h$counts[seq(limit+1,length(h$counts))])
data <- c(subset, rest)

labels <- c(seq(1,limit,1),paste(">",toString(limit), seq=""))

Read more

Syndicate content