I am trying to get the number of 0s (or count of) in a number of binary matrix csv files? Is there an efficient way of doing this for multiple csv files at once?
I have read in all the csv files from the set working directory using this code but I am unsure where to go from here...
matrices <- list.files(pattern="*.txt")
matrices <- lapply(matrices, read.delim)
An option is to create a logical matrix (
x == 0
) by looping through thelist
of data.frames (sapply
) and usesum
. In case, there areNA
values, use thena.rm = TRUE
(by default it isFALSE
)