here is another way of doing it using 'tidyr' and 'dplyr'
> x <- read.table(text = "CloneIDgenotype2001genotype2002
> genotype2003
+ 2471250111
+ 2471250000
+ 2433062000
+ 2433062111
+ 100021605110
+ 100021605101
On Mon, Aug 4, 2014 at 4:53 AM, raz wrote:
> Dear all,
>
> I have a data frame 144 x 2 values.
> I need to take every value in the first row and compare to the second row,
> and the same for rows 3-4 and 5-6 and so on.
> the output should be one line for each of the two row comparison.
> the c
You could try data.table
#dat is the dataset
library(data.table)
v1 <- setNames(c("HT", "A", "B", "Aht", "Bht"), c("11", "10", "01", "1-", "-1"))
dat2 <- setDT(dat1)[, lapply(.SD, function(x) v1[paste(x, collapse="")]),
by=CloneID]
A.K.
On Monday, August 4, 2014 5:55 AM, raz wrote:
Dear a
Hello, Raz,
if X is the data frame that contains your data, then using sort of an
"indexing trick" to circumvent your numerous if-statements as in
aggregate( X[ c( "genotype 2001", "genotype 2002", "genotype 2003")],
X[ "CloneID"],
FUN = function( x)
c(
Dear all,
I have a data frame 144 x 2 values.
I need to take every value in the first row and compare to the second row,
and the same for rows 3-4 and 5-6 and so on.
the output should be one line for each of the two row comparison.
the comparison is:
if row1==1 and row2==1 <-'HT'
if row1==1 an
5 matches
Mail list logo