[R] Combining 2 arrays into a third array via a function

Kevski ps at kevski.com
Sun Mar 1 17:47:30 CET 2009


I'm completely stumped and seem to be going around for 2 days in the wrong
circles. Here's what I have in 2 dataframes:

> dim(params.data); head(params.data, n=2)
[1] 284   6
  item        a1        a2   b1   b2   c
1    1 0.6671587 0.9588642 -3.5  -3.437961 0.2
2    2 1.1296298 1.4899307 -3.5  -4.146118 0.2

> dim(examinees.data); head(examinees.data, n=2)
[1] 1600    3
  examinee theta1 theta2
1        1     -3   -3.133437
2        2     -3   -3.293341

I also have a function, p(), that takes on values for a1, a2, b1, b2, c,
theta1, and theta2, then outputs a value.

I would like to produce a 3-column array that is 284*1600 = 454400 rows long
for my simulator. Somthing like:
  examinee    item  p
1            1      1   p-value
2            1      2   p-value
...
454399 1600 283   p-value
454400 1600 284   p-value

My brain seems to be stuck in a for-loop loop. I'm sure there is an elegant
and efficient R way to do this, but I can't seem to find the right brain
prompts in help pages, forum searches, or my trusty R Book. So, I appreciate
any guidance you might be able to provide.

Cheers,
Kev-
-- 
View this message in context: http://www.nabble.com/Combining-2-arrays-into-a-third-array-via-a-function-tp22274922p22274922.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list