0

Here there's an example:

car <- data.frame(matrix(c(2,NA,5,NA,7,6), nrow=3, ncol=2, byrow = FALSE))
colnames(car) <- c("a","b")

How can I write this part without repeating the code?

car$a[is.na(car$a)] <- 0
car$b[is.na(car$b)] <- 0
Ronak Shah
  • 355,584
  • 18
  • 123
  • 178
Sabri.
  • 183
  • 6

0 Answers0