Ok, then tapply() might be your friend:
set.seed(1)
b - rbinom(10,6,0.3)
c - rbinom(10,6,0.9)
w - trunc(runif(10)*3)
b;c;w
table(b, c)
tapply(w, list(b, c), sum)
Is this what you were looking for?
/Johan
G. Draisma skrev:
Thanks Johan,
I realize that I did not use the right example.
I
I have to compare four different grape varieties proteome in two different
years. I don't know what test would be more suitable for my data. I think that
an anova two way can be usefull also if someone suggested me to perform a
manova. In addiction, I can perform each test on a single protein a
Thank you Jim,
Sorry, that I was not clear enough.
Each case has a frequency variable N.
so when tabulating combinations (i,j) they
should be weighted with weight N.
In this case I would like a command
table(i,j,N)
resulting in
j
i 1 2
1 11 12
2 21 22
...
5 51 52
And I
Would it be ok with a matrix?
i - 1:5; j - 1:2
li - length(i)
lj - length(j)
A - matrix(numeric(li * lj), nrow = li, dimnames = list(i, j))
for (r in 1:li)
for (s in 1:lj)
A[r, s] - 10*r + s
A
HTH
/Johan
G. Draisma skrev:
Thank you Jim,
Sorry, that I was not clear enough.
Each case
Thanks Johan,
I realize that I did not use the right example.
I have a table with two factors, say b and c,
and a third case weight variable, say w.
Then I would like the table command to sum the weights w
for each combination of i and j.
For instance, with
b - rbinom(10,6,0.3)
c -
Hallo,
Im trying to find out how to tabulate frequencies
of factors when the data have a frequency variable.
e,g:
i-rep(1:5,2)
j-rep(1:2,5)
N-10*i+j
table(i,j) gives a table of ones
as each combination occurs only once.
How does one get a table with the corresponding N's?
Thanks!
Gerrit.
--
I am not exactly sure what you are asking for. I am assuming that you
want a vector that represent the combinations that are given
combinations that are present:
N
[1] 11 22 31 42 51 12 21 32 41 52
table(i,j)
j
i 1 2
1 1 1
2 1 1
3 1 1
4 1 1
5 1 1
z - table(i,j)
which(z==1)