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 following
arguments:
1) Where data points have two letters separated by a comma, e.g. "T,G",
replace with a "2"
2) Where single letter data points match the data point in the corresponding
row of the reference file, replace with a "0"
3) Where single letter data points do not match the reference file, replace
with a "1"
4) NA is left as NA

In the example, the output file would look like:

1 2 0 1
0 NA 1 1
2 0 0 NA

Any advice very much appreciated. Also, if you know of any good books or
online courses that can help me to learn how to deal with these sorts of
data handling queries, that is also great!

Thank you

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Comparison-of-two-files-with-multiple-arguments-tp2991043p2991043.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.

Reply via email to