Hi,

I just started using R for about one week and I have few problems.

i)I have a problem in finding right function to convert a table of natural
numbers to bitwise. For a simple example;

I have the below table:-

Column  Col1   Col2   Col3
Sample1 5        7      10
Sample2 0        2       1
Sample3 4         0       0


Supposedly i wanted to convert to :-


Column  Col1   Col2   Col3
Sample1 1        1       1
Sample2 0        1       1
Sample3 1         0       0

ii)Besides, I would like to create a formula of Sum(3*(Element in each
column for a row))..does it equivalent to 3*(data[1:3,1:2]) in this case?or
I need to have Sum(3*(data[1:3,1:2])). Basically I wanted to mutliply each
element of column table of a row and sum it  up.

iii)I would also like to know how to insert an if else statement where in
the above case, I wanted to check if data[1:3,]
returns me 1 or 0, it will execute some calculations.
I refer to the R intro pdf and it mentioned using if (expr_1 ) expr_2 else
expr_3. Does that mean if(data[1:3,1:2])>0 output[1:3,1:2]=0
else output[1:3,1:2]="100". If I did this command, how does R knows which
row and column to map the output with?

Please advise. Appreciate alot. Thanks.

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