Dear all,

 

propably this question sounds stupid to you, but since I'm new to R I got
some troubles regarding the following issue (The table below does not
represent my real data, it is just a simplified example):

 

My intention is to first subdivide my data into several groups of vectors,
let's say for instance 3 groups, such that group 1={A,B}, group2={C,D},
group3={E,F}. How can I do this even for a much larger data table (about
3'000 columns)??

 

After that I'd like to calculate weights for each element in the table as
follows: weight(ij)=element(ij)/sum(elements in a row per group). 

 

So, for example:

For the first element of column A: 1/(1+2)=1/3

For the first element of column B: 2/(1+2)=2/3

For the second element of column A: 2/(2+3)=2/5

And so forth.

 

Table 1:

 

A             B             C             D             E             F

1             2             3             4             5               9

2             3             4             5             6               8

3             4             5             6             7               7

4             5             6             7             8               6

5             6             7             8             9               5

 

 

I tried to do something like apply(Table1, 1, function(x)x/sum(x(i+1))) but
it returns an error (cannot find function x).

 

I would be truly grateful for any hints.

 

Many thanks in advance

Best, Sam

 

 

 


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