Hi, On Tue, Dec 7, 2010 at 3:01 PM, madr <madra...@interia.pl> wrote: > > In datamatrix[, "y"] == datamatrix[, "y"][-1] :
suppose datamatrix has 10 rows, you select column "y", and then for the equality remove the first 'row' (technically element at this point since you selected just column "y"). So R is being asked to try to compare rows 1 through 10 with rows 2 through 10 hence: > longer object length is not a multiple of shorter object length > > out = c(FALSE,datamatrix[,'y'] == datamatrix[,'y'][-1]) > > and I do not know why I get that error, the resulting out matrix is somehow > one row larger than datamatrix... > all I try to do is filter matrix by dropping rows where [,'y'][-1] == > [,'y'][+1] perhaps you want to compare rows 1 through 9 with 2 through 10? That is, see if there are any differences? Following through wtih there being 10 rows, you could remove the last one (replacing 10 with however many you actually have): datamatrix[, "y"][-10] == datamatrix[, "y"][-1] or alternately you might look at the ?diff function: diff(datamatrix[, "y"]) which will calculate differences based on the set lag (1 by default). It seems like you might be interested in something like that. Cheers, Josh > -- > View this message in context: > http://r.789695.n4.nabble.com/longer-object-length-is-not-a-multiple-of-shorter-object-length-tp3077400p3077400.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.