Re: [R] Comparison of two files with multiple arguments

2010-10-11 Thread Michael Bedward
Hello, Here's one way to do it. It assumes dat has character values, not factors. dat2 <- matrix(0, nrow(dat), ncol(dat)) dat2[ is.na(dat) ] <- NA dat2[ apply(dat, 2, function(x) grepl(",", x)) ] <- 2 dat2[ apply(dat, 2, function(x) x != ref) ] <- 1 Michael On 12 October 2010 13:24, burgundy

[R] Comparison of two files with multiple arguments

2010-10-11 Thread burgundy
Hello, I have an example file which can be generated using: dat <- read.table(tc <- textConnection( 'T T,G G T C NA G G A,T A A NA'), sep="") I also have a reference file with the same number of rows, for example: G C A I would like to transform the file to numerical values using the followin