How can I divide all values of a given column by a number? Lets say I have a dataframe that contains 10 columns and I need to divide by 1000 one of them. I've tried a couple of solutions bot none of them works well. Thanks!
Have you considered dividing by 1000 via dplyr::mutate()?
dplyr::mutate()
library(dplyr) frm <- data.frame(cats = c(1000, 2000, 3000)) print(frm) cats 1 1000 2 2000 3 3000 frm <- frm %>% mutate(dogs = cats / 1000) print(frm) cats dogs 1 1000 1 2 2000 2 3 3000 3
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.