foo can be written as a mapply:
t(mapply(pcm, items, score, MoreArgs = list(theta = theta)))
On 7/19/06, Doran, Harold <[EMAIL PROTECTED]> wrote:
> I need to wrap a loop inside a function and am having a small bit of
> difficulty getting the results I need. Below is a replicable example.
>
>
> #
Very true, the resounding echo was large.
Thanks, Doug.
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of Douglas Bates
> Sent: Wednesday, July 19, 2006 4:20 PM
> To: Doran, Harold
> Cc: r-help@stat.math.ethz.ch
> Subject
I'm sure when you read this there will be the sound of a palm slapping
a forehead. :-)
The value of a function is the value of the last expression evaluated
in the function. If you rewrite foo as
foo <- function(theta,items, score){
like.mat <- matrix(numeric(length(items) * length(theta)),
Doran, Harold wrote:
> I need to wrap a loop inside a function and am having a small bit of
> difficulty getting the results I need. Below is a replicable example.
>
>
> # define functions
> pcm <- function(theta,d,score){
> exp(rowSums(outer(theta,d[1:score],'-')))/
> apply(exp(apply
I need to wrap a loop inside a function and am having a small bit of
difficulty getting the results I need. Below is a replicable example.
# define functions
pcm <- function(theta,d,score){
exp(rowSums(outer(theta,d[1:score],'-')))/
apply(exp(apply(outer(theta,d, '-'), 1, cumsum)), 2, s