Hi @alexgalli,
Thanks for sharing the data, however, even the snippet you shared isn't easily usable via copy-and-paste. If you use the dput() function as mentioned by @Nate, the returned output can be directly used.
I spent a few minutes setting up your data so I could use it
data <- tribble(
~x, ~y, ~z, ~k,
3, 'DDR', 4.64, NA_character_,
3, 'DDR', 6.35, NA_character_,
3, 'DDR', 6.1, NA_character_,
57, NA_character_, 5.5, NA_character_,
1, 'DDR', 4.46, NA_character_,
1, 'DDR', 3.97, NA_character_,
0, 'ALCOHOLIC CIRRHOSIS', 7.44, NA_character_,
0, 'DDR', 4.03, NA_character_,
11, NA_character_, 6.66, NA_character_,
2, NA_character_,4.26, NA_character_
)
Running dput(data) on this data above would produce:
structure(list(x = c(3, 3, 3, 57, 1, 1, 0, 0, 11, 2), y = c("DDR",
"DDR", "DDR", NA, "DDR", "DDR", "ALCOHOLIC CIRRHOSIS", "DDR",
NA, NA), z = c(4.64, 6.35, 6.1, 5.5, 4.46, 3.97, 7.44, 4.03,
6.66, 4.26), k = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_)), row.names = c(NA, -10L), class = c("tbl_df",
"tbl", "data.frame"))
This can be copied and pasted easily into R.
Anyway, onto the original issue, I believe this code will do what you want.
map(data, ~filter(data, is.na(.)))
Note that the code will print out a list of data frames to console with an element for each variable in data. So if you have 100 variables, expect 100 data frames in a list printed to console. It might be easier to store it all in an object and inspect it using the Viewer in R. If you hover your mouse over the data frame you want to inspect, there should be an icon on the far-right that looks like a scroll, click it to inspect that data frame.
list_of_dfs <- map(data, ~filter(data, is.na(.)))
View(list_of_dfs)