One way of doing it:
df[, colSums(is.na(df)) != nrow(df)]
If the count of NAs in a column is equal to the number of rows, it must be entirely NA.
Or similarly
df[colSums(!is.na(df)) > 0]
More Related Contents:
- How do I replace NA values with zeros in an R dataframe?
- Replacing character values with NA in a data frame
- How to replace NA values in a table for selected columns
- Omit rows containing specific column of NA
- Count NAs per row in dataframe [duplicate]
- Subset of rows containing NA (missing) values in a chosen column of a data frame
- Remove columns from dataframe where some of values are NA
- How to subset data in R without losing NA rows?
- Randomly insert NAs into dataframe proportionaly
- Select last non-NA value in a row, by row
- Replace in a factor column
- Replace all NA with FALSE in selected columns in R
- Find columns with all missing values
- R: replacing NAs in a data.frame with values in the same position in another dataframe
- Move NAs to the end of each column in a data frame
- How to convert a list consisting of vector of different lengths to a usable data frame in R?
- Filtering a data frame on a vector [duplicate]
- Selecting multiple odd or even columns/rows for dataframe
- Deleting reversed duplicates with R
- Select every nth row from dataframe
- duplicates in multiple columns
- Extend contigency table with proportions (percentages)
- Check whether values in one data frame column exist in a second data frame
- How do you remove columns from a data.frame?
- Unlist a data frame by rows, not columns
- DT[!(x == .)] and DT[x != .] treat NA in x inconsistently
- Difference between `names(df[1])
- How to create a new variable in a data.frame based on a condition?
- Filtering rows in R unexpectedly removes NAs when using subset or dplyr::filter
- Interpolating timeseries