On Oct 8, 2009, at 3:47 PM, Khanh Nguyen wrote:

Hi all,

I have a question about hist()

1)
t1 <- hist(c(1,2,3,4,5))
t1
$breaks
[1] 1 2 3 4 5

$counts
[1] 2 1 1 1

why is there 2 counts for 1? And should the counts be '1 1 1 1 1' ?

It depends on the way the bins are defined.

Had you forced a particular set of breaks you would get a different set of bin boundaries.

t1 <- hist(c(1,2,3,4,5), breaks=c(1,2,3,4,5,6)-.1)


Is there any other function to count frequency of discrete data?

?table

> table(c(1,2,3,4,5))

1 2 3 4 5
1 1 1 1 1

Thanks.

-k

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to