[R] count combined occurrences of categories

arun smartpink111 at yahoo.com
Fri Jan 11 15:06:10 CET 2013

You could try this:

#  nam art deb joy mar seb lio nem tat
#1  da   2   3   1   4   1   1   0   0
#2  fr   2   2   2   3   0   1   1   1
#3  ya   1   2   1   0   0   1   1   0

----- Original Message -----
From: Biau David <djmbiau at yahoo.fr>
To: r help list <r-help at r-project.org>
Sent: Friday, January 11, 2013 5:54 AM
Subject: [R] count combined occurrences of categories

Dear all,
i would like to count the number of times where I have combined occurrences of the categories of 2 variables.
For instance, in the dataframe below, i would like to know how many times each author (au1, au2, au3 represent the first, second, third author) is associated with each of the category of the variable 'nam'. The position of the author does not matter.
nam <- c('da', 'ya', 'da', 'da', 'fr', 'fr', 'fr', 'da', 'ya', 'fr')
au1 <- c('deb', 'art', 'deb', 'seb', 'deb', 'deb', 'mar', 'mar', 'joy', 'joy')
au2 <- c('art', 'deb', 'mar', 'deb', 'joy', 'mar', 'art', 'lio', 'nem', 'mar')
au3 <- c('mar', 'lio', 'joy', 'mar', 'art', 'lio', 'nem', 'art', 'deb', 'tat')
tutu <- data.frame(cbind(nam, au1, au2, au3))

    [[alternative HTML version deleted]]

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list