Hi guys,

I was wondering if any one is able to help me on a problem that I was stuck
with for a long time. It involves the replacement of character strings with
numbers. The character string can take on only 3 possible values, for
instance:

AA
AT
TT

I would want R to replace AT with 0. Between AA and TT, I want to compare
the frequency of either value, and then for the one which occurs more, I
want it to be replaced with 1, and the other with -1. So using the same
example, say, I have

AA - 50
AT-34
TT- 57

I would want R to substitute it in this way:
AA= -1
AT=0
TT = 1

The strings are not necessarily AA,AT, or TT.

Any ideas?

Thanks!
Jeremy

        [[alternative HTML version deleted]]

______________________________________________
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