I have a list of data frames (gtf
) and I would like to calculate what proportion of each of these data frames have 0's at a set of coordinates [i,j] (coordinates [i,j] == 0). i.e. if I have 500 data frames and 120 of them have 0 at coordinates [1,1], then the function would return 120/500.
Eventually, I would like my function to return a data frame where the columns correspond to the columns of gtf
and the values are the proportions of data frames that had 0's in the corresponding coordinates. Here is a recreation of gtf
:
x = matrix(c(1,0), 6,6)
x = as.data.frame(x)
y = matrix(c(0,1), 6,6)
y = as.data.frame(x)
gtf = list(x,y,x,y)
Here is what I have tried:
for (i in seq_along(gtf))
for (j in seq_along(gtf[[i]]))
if (gtf[[i]][1,j] == 0) tf[[i]] <- TRUE