I have a list of list like below:
lst<- list(`101-01-101` = list(Demographics = structure(list(SubjectID = c("SubjectID",
"101-01-101"), BRTHDTC = c("BRTHDTC", "1953-07-07"), SEX = c("SEX",
"Female")), row.names = c(NA, -2L), class = c("tbl_df", "tbl",
"data.frame")), DiseaseStatus = structure(list(SubjectID = c("SubjectID",
"101-01-101"), DSDT = c("DSDT", "2016-03-14"), DSDT_P = c("DSDT_P",
NA)), row.names = c(NA, -2L), class = c("tbl_df", "tbl", "data.frame"
)), Visits = structure(list(SubjectID = c("SubjectID", "101-01-101"
), Visit = c("Visit", "Screening: -28 Days to Day 1"), VISND = c("VISND",
NA)), row.names = c(NA, -2L), class = c("tbl_df", "tbl", "data.frame"
))), `101-02-102` = list(Demographics = structure(list(SubjectID = c("SubjectID",
"101-02-102"), BRTHDTC = c("BRTHDTC", "1963-07-02"), SEX = c("SEX",
"Female")), row.names = c(NA, -2L), class = c("tbl_df", "tbl",
"data.frame")), DiseaseStatus = structure(list(SubjectID = c("SubjectID",
"101-02-102"), DSDT = c("DSDT", "2017-04-04"), DSDT_P = c("DSDT_P",
NA)), row.names = c(NA, -2L), class = c("tbl_df", "tbl", "data.frame"
)), Visits = structure(list(SubjectID = c("SubjectID", "101-02-102"
), Visit = c("Visit", NA), VISND = c("VISND", NA)), row.names = c(NA,
-2L), class = c("tbl_df", "tbl", "data.frame"))), `101-03-103` = list(
Demographics = structure(list(SubjectID = c("SubjectID",
"101-03-103"), BRTHDTC = c("BRTHDTC", "1940-09-11"), SEX = c("SEX",
"Male")), row.names = c(NA, -2L), class = c("tbl_df", "tbl",
"data.frame")), DiseaseStatus = structure(list(SubjectID = c("SubjectID",
"101-03-103"), DSDT = c("DSDT", NA), DSDT_P = c("DSDT_P",
NA)), row.names = c(NA, -2L), class = c("tbl_df", "tbl",
"data.frame")), Visits = structure(list(SubjectID = c("SubjectID",
"101-03-103"), Visit = c("Visit", "Screening: -28 Days to Day 1"
), VISND = c("VISND", NA)), row.names = c(NA, -2L), class = c("tbl_df",
"tbl", "data.frame"))))
I would like to change subjectID
input to NA
if a df
in the list only have the value in SubjectID
but NA
for all other variables. what should I do?
I am thinking of counting none NA
input for each df
, if the value equals 1, then remove all records or change SubjectID
to NA
. I would like to still keep the col names, But how to do that?
In my example file, 101-02-102
should have Visits as empty df
, and 101-03-103
should have DiseaseStatus
as empty df
.