I'm brand new to R and I'm trying to figure out how to sum the rows from the following output.
u <- c(1,2,3)
x <- lapply(u, replicate, rbinom(10,1,.5))
When I do this x is equal to
[[1]]
[,1]
[1,] 0
[2,] 0
[3,] 1
[4,] 1
[5,] 0
[6,] 1
[7,] 1
[8,] 1
[9,] 1
[10,] 0
[[2]]
[,1] [,2]
[1,] 0 1
[2,] 0 1
[3,] 1 0
[4,] 1 1
[5,] 1 1
[6,] 1 1
[7,] 1 1
[8,] 1 0
[9,] 1 0
[10,] 0 0
[[3]]
[,1] [,2] [,3]
[1,] 1 0 0
[2,] 1 1 1
[3,] 1 0 1
[4,] 1 0 1
[5,] 0 0 1
[6,] 0 0 1
[7,] 0 1 0
[8,] 1 1 1
[9,] 0 1 1
[10,] 0 1 1
When I use the coding
rowSums(x)
or
rowSums(x[2])
I get this error
Error in rowSums(x) : 'x' must be an array of at least two dimensions
How can I sum the rows? Also, is there a way to break up the tables so that I can do individual analysis. Preferably a way that is not manual so I can use it if I have 100+ tables