1、
> a <- c(3,NA,NA,4,1,5)
> b <- c(NA,4,6,2,4,9)
> c <- data.frame(a,b)
> c
a b
1 3 NA
2 NA 4
3 NA 6
4 4 2
5 1 4
6 5 9
> c[is.na(c)] <- 0
> c
a b
1 3 0
2 0 4
3 0 6
4 4 2
5 1 4
6 5 9
2、
> a <- c(3,NA,NA,4,1,5)
> b <- c(NA,4,6,2,4,9)
> c <- data.frame(a,b)
> c
a b
1 3 NA
2 NA 4
3 NA 6
4 4 2
5 1 4
6 5 9
> c[is.na(c)] <- "sss"
> c
a b
1 3 sss
2 sss 4
3 sss 6
4 4 2
5 1 4
6 5 9