Dear David and Mark,
thank you for your reply. I have implemented the suggestions you have
made in the following:
x - c(-Inf, Inf,NA,5.9,6.08,5281391136138.75,
4.35,4.79,
9474097322.96,3.64,16.42,-12211.11,4.37,
-1097.79,4.78,
On Apr 17, 2015, at 5:23 PM, Luigi Marongiu marongiu.lu...@gmail.com wrote:
Dear all,
I have a vector with a certain range of values including infinity and
NA. I would like to remove the values that are outside a given range
(lower level = ll and upper level = ul) but I am getting the error
Dear all,
I have a vector with a certain range of values including infinity and
NA. I would like to remove the values that are outside a given range
(lower level = ll and upper level = ul) but I am getting the error due
to the NA values (missing value where TRUE/FALSE needed). I then
included the
Hello again,
I have a question on who sum() handle the NA values.
sum(c(NA, 1), na.rm = TRUE)
[1] 1
I understand this. However could not agree with following:
sum(c(NA, NA), na.rm = TRUE)
[1] 0
Where this '0' is coming from? Should not it be NA itself?
Thanks and regards,
On Feb 16, 2013, at 11:55 AM, Christofer Bogaso bogaso.christo...@gmail.com
wrote:
Hello again,
I have a question on who sum() handle the NA values.
sum(c(NA, 1), na.rm = TRUE)
[1] 1
I understand this. However could not agree with following:
sum(c(NA, NA), na.rm = TRUE)
[1] 0
On 16-02-2013, at 18:55, Christofer Bogaso bogaso.christo...@gmail.com wrote:
Hello again,
I have a question on who sum() handle the NA values.
sum(c(NA, 1), na.rm = TRUE)
[1] 1
I understand this. However could not agree with following:
sum(c(NA, NA), na.rm = TRUE)
[1] 0
Thanks Marc for your reply.
However this leads to my problem of handling rowSums() function (hence
colSums()). Let take following matrix:
Mat - matrix(c(1, 1, NA, -1, 1, NA, NA, 1, NA), nc = 3)
Mat
[,1] [,2] [,3]
[1,]1 -1 NA
[2,]111
[3,] NA NA NA
rowSums(Mat,
Nothing comes to mind immediately for rowSums() or colSums() given the way in
which they handle things, however using apply() you have more flexibility,
albeit at the price of some speed:
apply(Mat, 1, function(x) if (all(is.na(x))) NA else sum(x, na.rm = TRUE))
[1] 0 3 NA
Essentially, if
Subject: Re: [R] Handling NA values
Thanks Marc for your reply.
However this leads to my problem of handling rowSums() function (hence
colSums()). Let take following matrix:
Mat - matrix(c(1, 1, NA, -1, 1, NA, NA, 1, NA), nc = 3)
Mat
[,1] [,2] [,3]
[1,] 1 -1 NA
[2,] 1 1 1
[3
9 matches
Mail list logo