[R] combine two columns

Gabor Grothendieck ggrothendieck at gmail.com
Tue Nov 29 16:03:09 CET 2005


Try this:

> is.odd <- !array(0:1, ncol(mat))
> mat[,is.odd] == mat[,!is.odd]
        A     B     C
row1 TRUE FALSE  TRUE
row2 TRUE  TRUE FALSE

On 11/28/05, Georg Otto <georg.otto at tuebingen.mpg.de> wrote:
> Hi,
>
> I have an R programming problem and I havent found anything in the
> documentation yet:
>
> I have a data matrix, in which two neighbouring columns represent
> replicates of the same experiment, e.g. something like this:
>
>       A A B B C C
> row1   1 1 1 2 2 2
> row2   1 1 1 1 1 2
>
> I would like to test, if the values for the two replicates in a row
> are the same or if they differ and generate a new matrix with the
> results of the tests, something like this:
>
>        A B C
> row1    T F T
> row2    T T F
>
> Any hint will be appreciated!
>
> Georg
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list