Re: [R] Counting Frequencies in Data Frame

2010-05-18 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of M.Ribeiro > Sent: Tuesday, May 18, 2010 7:13 AM > To: r-help@r-project.org > Subject: [R] Counting Frequencies in Data Frame > > > Hi, > I am sure

Re: [R] Counting Frequencies in Data Frame

2010-05-18 Thread Ista Zahn
Hi, Others will have fancier solutions, but is the way I would do it: dat <- read.table(textConnection("1 2 3 1 aa ab ab 2 ab ab ab 3 aa aa aa 4 bb bb bb"), header=TRUE) closeAllConnections() countAB <- function(x) { aa <- length(which(x == "aa")) ab <- length(which(x == "ab")) bb <- leng

[R] Counting Frequencies in Data Frame

2010-05-18 Thread M.Ribeiro
Hi, I am sure there is an easy way to do it, but I can't find it. I have a data frame that has 15 columns and 7000 rows. The only values inside the data.frame are "aa", "ab", "bb" as you can see an example bellow. 1 2 3 1 aa ab ab 2 ab ab ab 3 aa aa aa 4 bb bb bb What I would like to do, i