[R] vectorization help please

Alberto Murta amurta at ipimar.pt
Wed Sep 26 12:58:02 CEST 2001


im2[i,j] <- im[i,j] * (-1)^(row(im)+col(im))


Bill Simpson wrote:
> 
> What is a smarter way of doing:
> 
> for(i in 1:xn)
> for(j in 1:yn)
> {
> im2[i,j]<- im[i,j]* (-1)^(i+j)
> }
> 
> Thanks!
> 
> Bill
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
                       Alberto G. Murta                      
       IPIMAR - Institute of Fisheries and Sea Research
        Avenida de Brasilia, 1449-006 Lisboa, Portugal       
Tel: +351 213027062; Fax: +351 213015849; http://www.ipimar.pt
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list