I have the following data frame:
dat <- structure(list(`A-XXX` = c(1.51653275922944, 0.077037240321129,
0), `fBM-
Here's another option using the row-wise operations of dplyr (with col1,col2,col3
defining three exemplary columns for which the rowwise sum is calculated):
library(tidyverse)
df <- df %>%
rowwise() %>%
filter(sum(c(col1,col2,col3)) != 0)
Alternatively, if you have tons of variables (columns) to select you can also use the tidyverse selection syntax via:
df <- df %>%
rowwise() %>%
filter(sum(c_across(col1:col3)) != 0)
For details see: https://dplyr.tidyverse.org/articles/rowwise.html