Hello,
Currently I have a point where only a subset of items are produced between a
to e
. I likely will always end up with at least 2 of the 5 but not always the same. I have created a dummy example where we only have a
and b
containing values. I want a solution where we bind those that qualify to a data.frame while dropping the rest. As you can see so far it is working except where we have NAs
for column 3.
I want to have some way to drop these during the do.call
and also to retain their original names (hence column 1 should be called a and column 2 should be called b it shoudl work on those that qualify of course).
a <- factor(
x = c(0,1,1,0,1,1,0),
levels = c(0, 1),
labels = c("No", "Yes"))
b <- factor(
x = c(0,1,2,2,1,1,0),
levels = c(0, 1, 2),
labels = c("No", "Yes", "Maybe"))
c <- NA
d <- NULL
df_list <- list()
df_list[[1]] <- a
df_list[[2]] <- b
df_list[[3]] <- c
df_list[[4]] <- d
df_list[[5]] <- e
#> Error in eval(expr, envir, enclos): object 'e' not found
do.call(cbind,df_list)
#> [,1] [,2] [,3]
#> [1,] 1 1 NA
#> [2,] 2 2 NA
#> [3,] 2 3 NA
#> [4,] 1 3 NA
#> [5,] 2 2 NA
#> [6,] 2 2 NA
#> [7,] 1 1 NA
Created on 2020-10-11 by the reprex package (v0.3.0)