Re: [R] Delete the first instances of the unique values of a vector in R

2017-01-11 Thread Rui Barradas
Hello again, Sorry about my first answer, I hadn't read until the part you say you need a for loop. Why you need it seems strange to me but here it is. delete <- c(TRUE, dat$x[-1] != dat$x[-length(dat$x)]) result <- data.frame() for(i in seq_along(delete)){ if(!delete[i])

Re: [R] Delete the first instances of the unique values of a vector in R

2017-01-11 Thread Rui Barradas
Hello, Just see the following. x <- scan(text = " 1 4 4 4 4 4 4 6 6") dat <- data.frame(x, y = rnorm(length(x))) dat[-which(c(TRUE, dat$x[-1] != dat$x[-length(dat$x)])), ] And now instead of 'dat' call your dataset 'rwrdatafile', and the same for the column of interess. Hope this helps, Ru

Re: [R] Delete the first instances of the unique values of a vector in R

2017-01-11 Thread Sarah Goslee
I think you should probably go read some introductory material on R. There are lots of good references out there. R does not work in the same way as MATLAB. You should probably also read the posting guide, and this article on making good reproducible examples: http://stackoverflow.com/questions/59

[R] Delete the first instances of the unique values of a vector in R

2017-01-11 Thread Tunga Kantarcı
Consider a data frame which I name as rwrdatafile. It includes several variables stored in columns. For each variable there are 1000 observations and hence 1000 rows. The interest lies in the values of the second column of this data frame, that is in rwrdatafile[,2]. What I am trying to accomplish