[R] Binary data sets
(Ted Harding)
Ted.Harding at manchester.ac.uk
Sat Nov 10 10:32:44 CET 2007
On 09-Nov-07 23:11:02, pedrosmarques at portugalmail.pt wrote:
> Hi,
>
> I would like to know if there is any algorithm in R for transforming
> Binary data sets. I want something like taking all the zeros and giving
> them some negative value, for example -5, and taking all ones and
> giving them some positive value, if it had been given -5 for zeros it
> would be 5 for all ones.
This could be done in various extremely simple ways.
In the case of your example, suppose that X is a vector containing
only the values 0 and 1. Then
-5 + 10*X
will give a result which has -5 where X has 0, and +5 where X has 1.
Another approach would be on the lines of
-5*(X==0) + 5*(X==1)
Hoping this helps,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 10-Nov-07 Time: 09:32:41
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list