Hi Liliana,

Try

> table(factor(x, levels = 0:10))

 0  1  2  3  4  5  6  7  8  9 10
 0  2  0  6  0  2  2  1  0  1  6

Also, see ?factor.

HTH,
Jorge


On Tue, Nov 23, 2010 at 10:29 PM, Liliana Pacheco <> wrote:

> Hi R users
> I want to make a table of frequencies to show how many times the numbers
> form 0 to 10 appear in a vector.
> For example, if the vector is:
>
> > x
>  [1]  5 10  3  5 10 10  3  6 10  1 10  3  7  1 10  3  6  9  3  3
>
>
> In this case I want a table that will show that the zero has frequency 0,
> the one has frequency 2, the three has a frequency of 6.... and so on.
> Notice that it has to show me that the 2, the 4, the 8 have a frequency of
> zero.
>
> The "table" function doesn't show me this.
>
> > table(x)
> x
>  1  3  5  6  7  9 10
>  2  6  2  2  1  1  6
>
>
> Thank you so much!
>
>        [[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.
>

        [[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.

Reply via email to