NULL NA Infinite

Published by onesixx on

 

> a <- c(Inf, 1, 2, NA, 3, NA, -Inf)
> a
[1]  Inf    1    2   NA    3   NA -Inf

> a[which(is.infinite(a)|is.na(a)|is.null(a))] <- 0
> a
[1] 0 1 2 0 3 0 0

 

 

> a <- c(Inf, -Inf, 1, 3, 4)
> a
[1]  Inf -Inf    1    3    4

> a[which(is.infinite(a))] <- 0
> a
[1] 0 0 1 3 4

 

> a <- NULL
> a
NULL

> a[which(is.null(a))] <- 0
> a
[1] 0

 

> a <- c(1, 2, NA, 3, NA)
> a
[1]  1  2 NA  3 NA
> a[which(is.na(a))] <- 0
> a
[1] 1 2 0 3 0

 

 

 

 

Categories: Reshaping

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x