I have a question on RowSums.
Lets say i have a timeSeries table
A B C
1/1/90 NA 1 1
1/2/90 NA 1 1
1/3/90 NA 1 1
1/4/90 NA 1 1
1/5/90 1 1 1
1/6/90 1 1 1
if i use RowSums, i will get
1/5/90 3
1/6/90 3
but i want
1/1/90 2
1/2/90 2
1/3/90 2
1/4/90 2
1/5/90 3
1/6/90 3
I cant figure out a way without doing loop.
Thanks
Cameron
--
View this message in context:
http://r.789695.n4.nabble.com/RowSums-Question-tp3049261p3049261.html
Sent from the R help mailing list archive at Nabble.com.
Try this: rowSums(tsObj, na.rm = TRUE) On Thu, Nov 18, 2010 at 3:58 PM, cameron <raymond.fu@invesco.com> wrote:> > > I have a question on RowSums. > > Lets say i have a timeSeries table > A B C > 1/1/90 NA 1 1 > 1/2/90 NA 1 1 > 1/3/90 NA 1 1 > 1/4/90 NA 1 1 > 1/5/90 1 1 1 > 1/6/90 1 1 1 > > if i use RowSums, i will get > > 1/5/90 3 > 1/6/90 3 > > > but i want > > 1/1/90 2 > 1/2/90 2 > 1/3/90 2 > 1/4/90 2 > 1/5/90 3 > 1/6/90 3 > > I cant figure out a way without doing loop. > > Thanks > Cameron > > -- > View this message in context: > http://r.789695.n4.nabble.com/RowSums-Question-tp3049261p3049261.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
thanks Henrique
I have another question.
Lets say i have a timeSeries table
A B C
1/1/90 NA 1 2
1/2/90 NA 1 1
1/3/90 NA 1 -1
1/4/90 NA -1 1
1/5/90 1 1 1
1/6/90 1 51 1
I want to count is.numeric. since NA is not numeric
A
1/1/90 2
1/2/90 2
1/3/90 2
1/4/90 2
1/5/90 3
1/6/90 3
Thanks again :)
Cameron
--
View this message in context:
http://r.789695.n4.nabble.com/RowSums-Question-tp3049261p3049421.html
Sent from the R help mailing list archive at Nabble.com.