Counting the amount of letters in all permutations of words in R
Posted
by
Rhodo
on Stack Overflow
See other posts from Stack Overflow
or by Rhodo
Published on 2013-11-13T15:47:01Z
Indexed on
2013/11/13
15:53 UTC
Read the original article
Hit count: 228
I have some words:
shapes<- c("Square", "Triangle","Octagon","Hexagon")
I want to arrange them in pairs:
shapescount<-combn(shapes, 2)
shapescount
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] "Square" "Square" "Square" "Triangle" "Triangle" "Octagon"
[2,] "Triangle" "Octagon" "Hexagon" "Octagon" "Hexagon" "Hexagon"
I want to count each of the groupings of the letters in the pairs, for instance first pair is "6" for "Square" and "8" for "Triangle" giving me "14" for the first pair, and so on.
© Stack Overflow or respective owner