Re: [R] Notation for previous observation in a data frame

2012-07-08 Thread Joshua Wiley
Hi Ernie, I'll use the built in mtcars dataset for demonstrative purposes. You have some condition, which can be used to create an index ## show data frame mtcars ## create index based on your condition i - which(mtcars$carb == 1) ## set those rows of mtcars in your index ## to the index - 1

Re: [R] Notation for previous observation in a data frame

2012-07-08 Thread arun
the single variable. e.g. dat1$var1[6:10]-dat1$var[5:9] A.K. - Original Message - From: Ernie Tedeschi ernie.tedes...@gmail.com To: r-help@r-project.org Cc: Sent: Saturday, July 7, 2012 11:20 PM Subject: [R] Notation for previous observation in a data frame I've created a data frame in R

[R] Notation for previous observation in a data frame

2012-07-07 Thread Ernie Tedeschi
I've created a data frame in R, but in order to clean up some of the data, I need to set certain variable observations equal to the value of their previous observation (it would be conditional, but that part's less important right now). In Stata, I would simply set var = var[_n-1] in those cases.