I assume that the responses that John already received to his recent
post met his needs. However, when I read it, I had a slightly
different interpretation. So feel free to ignore the rest of this post
if you like, but here's my interpretation and a simple solution to it.
An example to help explai
Às 01:25 de 29/11/2024, Sorkin, John escreveu:
I need to write code that will give me the previous value of from a data.frame.
I have written the following code using the shift function from data.table . It
does not work. I hope someone can help me correct the code.
###
Hi,
is there a specific reason to use "shift"? I mean, you could easily
achieve what you described by simple indexing:
--- snjp ---
for (i in 1:10) {
cat("x[i,num]",x[i,"num"],"\n")
# Get previous value of x[i,"num"]
zoop<-x[i-1,"num"] # NB! Returns "integer(0)" for ro
I need to write code that will give me the previous value of from a data.frame.
I have written the following code using the shift function from data.table . It
does not work. I hope someone can help me correct the code.
###
# Try to understand shift #
#
4 matches
Mail list logo