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

Steve Lianoglou mailinglist.honeypot at gmail.com
Tue May 24 22:30:20 CEST 2011


Hi,

On Tue, May 24, 2011 at 9:46 AM, Xenimes <acasusa at gmail.com> wrote:
> Thank you David and Steve,
>
> Yes all this data are already in R and in csv files.

That's nice, but as I said before: please use 'dput' or 'dump' on your
data.frame (or some reasonable portion of it) and paste that result
into an email so that anyone trying to help you can copy that and
paste it into an R session so they can more easily help you.

-steve

> Sorry for not being clear.
>
> I have this:
>
> Codes1and3[1:5,c(1:5)]
>        Mark_2 pop      Mark_1  Mark_3 age
> 1       P       A1      139     alpha   2
> 2       P       A1      140     alpha   2
> 3       P       A1      141     gamma   2
> 4       S       A1      142    gamma   2
> 5       S       A1      143    alpha   2
> 6       T       A2      144     alpha   2
> 7       T       A2      145     alpha   2
>
> I’m comparing Marks 1 and 3, then I need to know if the ones in Mark_2 in
> the general table have 1 or more interactions with Mark 3. For example here
> “P” appears in the same row than “alpha” and then in the same than “gamma”,
> then there are 2 interactions, so in a Boolean code it should be 1 (more
> than1 interaction).
> The same for “S”. But “T” only interacts with “alpha”, that will make it
> only one interaction = 0.
>
> The next colum I need is Code 1 referent to code 3 and in this case it
> should look like this:
>        Code 1_3
> 1       1
> 2       1
> 3       1
> 4       1
> 5       1
> 6       0
>
> I have tried to count but, of course in this case it will always be one,
> because they are linked in each row once, how can I consider the other rows?
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/How-do-I-assign-boolean-o-1-values-to-a-column-tp3544304p3547156.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>



-- 
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