my data:
structure(list(col1 = 1:6, col2 = c(NA, NA, 3L, 4L, 5L, 6L),
col3 = c(1L, 1L, NA, 1L, NA, 1L), col4 = c(2L, 2L, 2L, 2L,
NA, 2L), col5 = c(3L, 3L, 3L, NA, 3L, 3L), GROUP = c(1L,
1L, 1L, 2L, 2L, 2L)), class = "data.frame", row.names = c(NA, -6L))
I want to get a new date frame in which, if NA occurs, then replace the entire line with NA from the combination list(c(1,2),c(3,4,5)).
What I want to get:
data= structure(list(col1 = c(NA, NA, 3L, 4L, 5L, 6L), col2 = c(NA,
NA, 3L, 4L, 5L, 6L), col3 = c(1L, 1L, NA, NA, NA, 1L), col4 = c(2L,
2L, NA, NA, NA, 2L), col5 = c(3L, 3L, NA, NA, NA, 3L), GROUP = c(1L,
1L, 1L, 2L, 2L, 2L)), class = "data.frame", row.names = c(NA,
-6L))
UPDATE: I tried to do so:
list_v <- list(c(1,2),c(3,4,5))
data1 <- do.call(qpcR:::cbind.na, lapply(list_v, function(i)data[complete.cases(data[c(i)]),i]))
I need not to delete the line with Where there is at least one NA, but to replace the remaining elements with Na where there is at least one Na