I have a data.frame that looks like this:
C1 C2 C3 C4 1 -1 -1 1 1 1 -1 1 1 1 -1 1 1 -1 1 -1
I would like to count -1 and 1 occurrences by columns so I used:
tab= apply(DF, 2, table)
After I used the following string:
final <- as.data.frame(do.call("cbind", tab))
to write the result as data.frame. Unfortunately it gives me back an error because of the first element:
tab[[1]]
1
4tab[[2]]
-1 1
2 2..........
So I would like to add 0 to tab[[1]]
regarding -1 frequencies to be able to write the results as data.frame.