[Solved] Replace values greater than zero with 1 in r


The following will convert all non-zero numeric values to 1:

df.richness %>% mutate_if(is.numeric, ~1 * (. != 0))

while

df.richness %>% mutate_if(is.numeric, ~1 * (. > 0))

will do that with those greater than zero.

solved Replace values greater than zero with 1 in r