r - How do I get information for new element in column from other rows in dataframe? -


for project want total time used scrabble. have data frame in there localtime column. want add column dataframe difference between localtime now, , localtime previous element. when using diff function, following message:

error in `$<-.data.frame`(`*tmp*`, "timespend", value = c(1.5577, 1.0657,  :    replacement has 49313 rows, data has 49314 

how can fix this?

at moment have used this:

dualtasktime$timespend <- na dualtasktime$timespend <- diff(dualtasktime$localtime) 


Comments

Popular posts from this blog

python - PyInstaller UAC not working in onefile mode -

python - RuntimeError: can't re-enter readline -

php - Need to store a large amount of data in session with CI 3 but on storing large data in session it is itself destorying automatically -