Hi,
I just noticed that you also have all is.na() or !is.na() subsets. To do that:
mydatatest - structure(list(CaseID = structure(1:8, .Label = c(1605928,
1605943, 1605945, 1605947, 1605949, 1605951, 1605952,
1605953), class = factor), Structure = structure(c(1L, 1L,
3L, 2L, 2L, 3L, 3L, 4L),
I'm trying to count the number of combinations of columns containing data
not containing data as described below. Im not sure how to do this in R
and need some help.
#get TRUE/FALSE count of various combinations of columns per CaseID or per
Structure
mydatatest - data.frame (CaseID = c(1605928,
Hi,
May be this helps:
res - lapply(seq(length(vec1)-1),function(i) {x1 -
as.data.frame(combn(vec1,i),stringsAsFactors=FALSE); lapply(x1, function(x)
{indx - vec1 %in% x; nisna - paste(paste0(!is.na,(,
vec1[!indx],)),collapse= );isna - paste(paste0(is.na,(,
vec1[indx],)),collapse=
If you want to identify the combination of columns:
names1 - unlist(lapply(seq(length(vec1)-1),function(i) {x1 -
as.data.frame(combn(vec1,i),stringsAsFactors=FALSE); unlist(lapply(x1,
function(x) {indx - vec1 %in% x; paste(paste(paste0(!is.na,(,
vec1[!indx],)),collapse= ),
4 matches
Mail list logo