Hi

[hidden email] napsal dne 18.01.2011 13:51:05:

>

> Hi,

>

> I have this character vector:

>

> A<-c("Tell me how many different letter this vector has?")

>

> Is there a way with R that it can let me know how many different letters

I

> have on this vector?

A<-c("Tell me how many different letter this vector has?")

x<-strsplit(A, "")

> x

[[1]]

[1] "T" "e" "l" "l" " " "m" "e" " " "h" "o" "w" " " "m" "a" "n" "y" " "

"d" "i"

[20] "f" "f" "e" "r" "e" "n" "t" " " "l" "e" "t" "t" "e" "r" " " "t" "h"

"i" "s"

[39] " " "v" "e" "c" "t" "o" "r" " " "h" "a" "s" "?"

> table(x)

x

? a c d e f h i l m n o r s t T v w y

8 1 2 1 1 7 2 3 2 3 2 2 2 3 2 5 1 1 1 1

> length(table(x))

[1] 20

>

Regards

Petr

BTW. There are help pages coming with R installation. Do you have them

corrupted? There is strsplit in see also section of nchar help page.

>

> If I use nchar(A) que gives me the number 50. With this function he is

> counting all the letters present and also spaces between the words. Can

we

> also not count the spaces between words?

>

> Then after I knew how many different letters there were on the vector I

> wanted to table the number of times each letter is present to calculate

the

http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.

______________________________________________

[hidden email] mailing list

https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide

http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.