You almost have it. Put those two together:
SelectVar[, colSums(SelectVar != 0) > 0]
This works because the factor columns are evaluated as numerics that are >= 1.
More Related Contents:
- Repeat each row of data.frame the number of times specified in a column
- Filter data.frame rows by a logical condition
- Split column at delimiter in data frame [duplicate]
- Pass a data.frame column name to a function
- Select groups based on number of unique / distinct values
- Assign multiple columns using := in data.table, by group
- Filtering a data frame on a vector [duplicate]
- How to replace NA values in a table for selected columns
- Remove an entire column from a data.frame in R
- Selecting multiple odd or even columns/rows for dataframe
- Take random sample by group
- Split dataframe into multiple output files
- Replacing values from a column using a condition in R
- Split data.frame by value
- How to use a string variable to select a data frame column using $ notation [duplicate]
- Growing a data.frame in a memory-efficient manner
- R list of lists to data.frame
- Remove columns from dataframe where some of values are NA
- Check whether values in one data frame column exist in a second data frame
- How do you remove columns from a data.frame?
- Deleting columns from a data.frame where NA is more than 15% of the column length [duplicate]
- Using lapply to apply a function over list of data frames and saving output to files with different names
- DT[!(x == .)] and DT[x != .] treat NA in x inconsistently
- Return df with a columns values that occur more than once [duplicate]
- Row-wise sum of values grouped by columns with same name
- Replicate each row of data.frame and specify the number of replications for each row?
- Convert a data frame to a data.table without copy
- How can I merge more than 2 dataframes in R by rownames?
- Identifying where value changes in R data.frame column
- What is the first column in R’s mtcars dataset?