Hi all! I've been trying to figure how to select only the columns whose values(observations) themselves fit certain conditions.
For example, I want to answer the question;
"Which columns contain observations whose values are "NA", "NaN", or "-99" and what is the count for each value?"
I'm ultimately trying to construct a function that will tell R to search my_data and print the following:
- column name and under each column a
- tally of;
a. NA values
b. NAN values
c. specific values (like -99 (negative ninety nine) for example) - while excluding all other columns that do not contain observations which fit the above conditions.
Can this be done? I've scoured the web, the online R documentation, and youtube vides to no avail. There is a lot of detailed information on the "select()" function but I need to be able to select columns based
on row data, kind of like a pivoted version of "filter()".
Some of the functions I've been working with include;
colSums(is.na(my_data))
colSums(is.nan(my_data))
If possible, the bare minimum I hope to learn is how one can specify colSums() to look at specific integers or factors?
Thanks in advance!