Re: [R] How to count combinations

2012-10-08 Thread arun
Hi, Another way to get the matrix with combinations of two columns: just use table() dat1<-structure(list(Env = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("23", "55", "67", "Env"), class = "factor"), place = structure(c(7L, 7L, 7L, 2

Re: [R] How to count combinations

2012-10-08 Thread arun
Hi, Not clear how you want your output in matrix: Try this: dat1<-structure(list(Env = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("23", "55", "67", "Env"), class = "factor"), place = structure(c(7L, 7L, 7L, 2L, 1L, 11L, 11L, 11L,

Re: [R] How to count combinations

2012-10-08 Thread Rui Barradas
Hello, Your dataset seems to have a problem, the first row should the columns' names. If I'm right, nms <- levels(dat[[1]])[dat[1,1]] nms[2] <- levels(dat[[2]])[dat[1,2]] dat <- dat[-1, ] names(dat) <- nms with(dat, table(Env, place)) If I'm wrong, with(dat, table(V1, V2)) Hope this help