Yes, I'm sorry ... i was checking for another column so i made a mistake.
Thank you people ;)
--
View this message in context:
http://r.789695.n4.nabble.com/How-to-count-the-number-of-different-elements-in-a-column-tp4650825p4650875.html
Sent from the R help mailing list archive at Nabble.
Hello,
You're wrong, unique doesn't count unique returns a vector without
repetitions.
unique(a) # includes 1 and 4
[1] 1 2 3 6 7 8 4
length(unique(a))
[1] 7
Hope this helps,
Rui Barradas
Em 26-11-2012 14:55, Hard Core escreveu:
this is wrong because with the command "unique" it counts th
Hi,
Imagine the column is named XX.
Type:
> nrow(table(banca_impresa$XX))
and you'll get how many different categories there are in that column.
(If you type
> table(banca_impresa$XX)
you'll get the frequencies).
José
José Iparraguirre
Chief Economist
Age UK
T 020 303 31482
E jose.iparra
> 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 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 kn
My apologies.
I still do not understand the difference; good luck.
Hard Core wrote
> this is wrong because with the command "unique" it counts the only values
> that are unique ..
>
> in my column, for instance, 1 and 4 are not unique so the formula doesn't
> work in my case
--
View this m
length(unique(a))
Hard Core 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
> Ho
this is wrong because with the command "unique" it counts the only values
that are unique ..
in my column, for instance, 1 and 4 are not unique so the formula doesn't
work in my case
--
View this message in context:
http://r.789695.n4.nabble.com/How-to-count-the-number-of-different-elements-i
7 matches
Mail list logo