-3

_range=10

ret[_range:] = ret[_range:] - ret[:-_range]

here ret is NumpyArray in python

now please suggest me , how can i do this with R

jony
  • 924
  • 10
  • 25
  • Not everybody knows Python so please try explaining what you are trying to do by giving an example and show expected output for the same/ – Ronak Shah Oct 08 '19 at 07:25
  • @RonakShah i am done with that problem ,can you tell me how to do `[::2]` this operation in R – jony Oct 08 '19 at 08:46
  • 1
    Again, I don't know what `[::2]` does in Python so please try to explain clearly with an example. – Ronak Shah Oct 08 '19 at 08:47
  • @RonakShah if `list=[1,2,3,4,5,6,7,8] ` after this [::2] , we get `output=[1,3,5,7]` this is what it does – jony Oct 08 '19 at 08:50
  • 1
    This is the answer to `[::2]` in R https://stackoverflow.com/questions/13461829/select-every-other-element-from-a-vector – Ronak Shah Oct 08 '19 at 08:51

1 Answers1

2

simple way to do this

Try this

tail(ret,-range ) - head(ret,-range )

maybe you will find alternet way as well

Coder
  • 1,129
  • 10
  • 24