I have a tibble (dataframe) and I would like to select numeric elements greater than some number (e.g., 20) and update them to a new value (e.g., 0) like this:
mtcars_tbl <- as_tibble(rownames_to_column(mtcars))
mtcars_tbl[mtcars_tbl > 20] <- 0
However this also updates my rownames column which is a character variable that I want to preserve. Normally I would store my rownames in the rownames attribute of my dataframe. But tibbles don't support rownames anymore - which is a little annoying. Is there some other obvious solution I'm missing (apart from converting my data to a data.frame and back to a tibble)?