[R] help

Dominique Katshunga dkat at stats.uct.ac.za
Mon Sep 5 14:06:24 CEST 2005


Dear helpeRs,
I seem to be a little bit confused on the result I am getting from the
few codes below:
> u=v=seq(0,1,length=30)
> u
 [1] 0.00000000 0.03448276 0.06896552 0.10344828 0.13793103 0.17241379
 [7] 0.20689655 0.24137931 0.27586207 0.31034483 0.34482759 0.37931034
[13] 0.41379310 0.44827586 0.48275862 0.51724138 0.55172414 0.58620690
[19] 0.62068966 0.65517241 0.68965517 0.72413793 0.75862069 0.79310345
[25] 0.82758621 0.86206897 0.89655172 0.93103448 0.96551724 1.00000000
> v
 [1] 0.00000000 0.03448276 0.06896552 0.10344828 0.13793103 0.17241379
 [7] 0.20689655 0.24137931 0.27586207 0.31034483 0.34482759 0.37931034
[13] 0.41379310 0.44827586 0.48275862 0.51724138 0.55172414 0.58620690
[19] 0.62068966 0.65517241 0.68965517 0.72413793 0.75862069 0.79310345
[25] 0.82758621 0.86206897 0.89655172 0.93103448 0.96551724 1.00000000
> f=function(x,y){cp=max(x+y-1,0)}
> z=outer(u,v,f)
z is a 30x30 matrix which is fine, but why all its entries are equal to
1? for example, the maximum between u[22]+v[22]-1 and 0 is not 1?? I
don't really know where I went wrong! 
thanks,
Dominique




More information about the R-help mailing list