[R] [R/S] question re solution
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Thu Sep 2 09:30:43 CEST 2004
Erin Hodgess <hodgess at gator.uhd.edu> writes:
> a <- 0.5*(outer(1:n3,1:n3,function(x,y,n2.=n2){n2. - pmax(x,y)}))
> Why doesn't this work please?
Because defaults are expressions to be evaluated in the function's
evaluation frame (i.e. the expression could depend on x and y for
instance). When you evaluate the function, it goes looking for n2 --
and you're back to square one, basically. You might use substitute to
poke a precomputed n2 into the function definition, but it isn't
pretty.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list