Hello, everybody
Say I have
nm1 - c(rep(1,10), rep(0,10))
then I can do:
diff(nm1)
to see where I have shift in value
but what if I have
nm2 - c(rep(SPZ8, 10), rep(SPX9, 10))
how can I produce the same ouput as diff(nm1) does, that is zeros
everywhere except for one place where SPZ8 changes to
2009/3/13 Sergey Goriatchev serg...@gmail.com:
Say I have
nm1 - c(rep(1,10), rep(0,10))
then I can do:
diff(nm1)
to see where I have shift in value
but what if I have
nm2 - c(rep(SPZ8, 10), rep(SPX9, 10))
how can I produce the same ouput as diff(nm1) does, that is zeros
everywhere
Hi:
For A, you can use head and tail but you have to add a zero the front.
For B, you can use the same function, but put it inside an sapply and
run over the columns and then cbind it back with the original dataframe.
A)
nm2 - c(rep(SPZ8, 10), rep(SPX9, 10))
-1.0*c(0,as.numeric((head(nm2,-1)
Fabulous, guys!
Let me try your suggestions.
Thanks a lot!
Best,
SErgey
On Fri, Mar 13, 2009 at 11:53, markle...@verizon.net wrote:
Hi:
For A, you can use head and tail but you have to add a zero the front.
For B, you can use the same function, but put it inside an sapply and run
over the
4 matches
Mail list logo