How do I replace all number >1 with 1 in a data frame. The data is to be converted to 1 to signify presence vs absence of species. The headings are:
Date Site Time New.File.Name Frame.Number File.Name Mantas IDs. Whale.Shark Thresher.Shark Tiger.Shark Turtle Hammer.Head Grey.Reef.Shark White.Tip.Reef.Shark
I have abundance and I am trying to convert to richness
> TN %>% mutate_if(is.numeric, ~1 * (. != 0)) #To convert all non-zero numeric values to 1
Error in TN %>% mutate_if(is.numeric, ~1 * (. != 0)) :
could not find function "%>%"
> TN -> mutate_if(is.numeric, ~1 * (. != 0)) #To convert all non-zero numeric values to 1 --> didnt work
Error in mutate_if(is.numeric, ~1 * (. != 0)) <- TN :
could not find function "mutate_if<-"