[R] How to count the number of different elements in a column

Sarah Goslee sarah.goslee at gmail.com
Mon Nov 26 17:41:27 CET 2012


> x <- c(1, 2, 3, 1, 6, 7, 8, 3, 4, 4)
> length(unique(x))
[1] 7

On Mon, Nov 26, 2012 at 5:20 AM, Hard Core <gioxc at hotmail.it> wrote:
> Hello,
> Suppose that i have a dataframe
> a <- read.dta("banca_impresa.dta")
>
> i have a column with 17900 obs like
>
> 1
> 2
> 3
> 1
> 6
> 7
> 8
> 3
> 4
> 4
>
> and i want to know the number of the different values so in this case it
> would be 7
> How can i do?
> Thank you
>
>

--
Sarah Goslee
http://www.functionaldiversity.org




More information about the R-help mailing list