[R] How do I assign boolean (o,1) values to a column?

Steve Lianoglou mailinglist.honeypot at gmail.com
Tue May 24 04:59:06 CEST 2011


Hi CAR,

On Mon, May 23, 2011 at 10:52 AM, CAR <acasusa at gmail.com> wrote:
> Hi everybody!!
>
> I'm trying to assign boolean values to a column in a matrix depending on the
> number of times present in another column. I have no clue, I have been 2
> days looking for a way, if somebody knows what kind of functions I need to
> use I will really apreciate it.
>
> example:
>
> Color Type  Mark1 Mark2 Mark3
> Red   high    139    P       alpha
> blue   low    140    P        alpha
> Green high   141    S       alpha
> Yellow low    142   S        beta
> Red    high   143    P       gamma
>
> If we only take into account columns Mark1, Mark2 and Mark3. I would like to
> ask R to write another column with 0=one; 1=more than one.
> If alpha is present for more than one Mark 2, so P and S, then I will like
> to assign value 1 if only for one then assign the value 0.

I'm having trouble understanding what you want the values in new
column to be. Can you please provide the output of what you want your
desired data.frame to look like with the new column appended?

Also, for your "example" data.frame (the one you pasted above), I
guess you have it in your R workspace. Let's say it is called
'my.data', can you please paste the output of the following command
into the email as well:

R> dput(my.data)

This will provide us with a piece of text we can copy from your email
and paste into our R workspace so we can get your data up and running
easily.

Thanks,
-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact



More information about the R-help mailing list