I am trying to get a frequency table from this dataframe:
tmp2 <- structure(list(a1 = c(1L, 0L, 0L), a2 = c(1L, 0L, 1L),
a3 = c(0L, 1L, 0L), b1 = c(1L, 0L, 1L),
b2 = c(1L, 0L, 0L), b3 = c(0L, 1L, 1L)),
.Names = c("a1", "a2", "a3", "b1", "b2", "b3"),
class = "data.frame", row.names = c(NA, -3L))
tmp2 <- read.csv("tmp2.csv", sep=";")
tmp2
> tmp2
a1 a2 a3 b1 b2 b3
1 1 1 0 1 1 0
2 0 0 1 0 0 1
3 0 1 0 1 0 1
I try to get a frequency table as follow:
table(tmp2[,1:3], tmp2[,4:6])
But I get :
Error in sort.list(y) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?
Expected output:
Info: It is not necessary a square matrix for instance I should be able to add b4 b5 and keep a1 a2 a3