You can use the subset function in R to retain all records while filtering for non-NA values in a column based on a condition in another column.
For example, if you have a data frame called "df" with columns "col1" and "col2", and you want to keep all rows where "col1" is greater than 5 and "col2" is not NA, you can use the following code:
subset(df, col1 > 5 & !is.na(col2))
This code will filter the data frame to only include rows where "col1" is greater than 5 and "col2" is not NA. All other rows will be excluded.
Asked: 2022-12-03 11:00:00 +0000
Seen: 2 times
Last updated: Dec 30 '22