[R] question

John Kane jrkrideau at yahoo.ca
Wed Dec 19 20:42:59 CET 2007


I think this is what you want.

Y[Y>0] <- 1

--- "Armelini, Guillermo" <DOCGArmelini at iese.edu>
wrote:

> Hello everyone!
>  
> Is anybody can help me to solve this silly question
> that unfortunately I haven't found the right way to
> address it.
>  
> Supose I have a matrix X[n,n] dimension
>  
> I would like to calculate the product of the vectors
>  
> Y=X[1,n]*X[n,1]
>  
> Then I would like to run the following operation
>  
> H=if(Y>0) {H[,1]=1}
>  
> The problem is that the condition "if" works only
> for the first element of the matrix.
>  
> Does anybody knows how to apply the conditional "if"
> to a entire vector?
>  
> cheers
>  
> Guillermo
>  
> 
> 
> This message has been scanned for viruses by
> TRENDMICRO,
> an IESE technology affiliate company  and global
> leader in antivirus and content security software.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
> 



      Looking for the perfect gift? Give the gift of Flickr!



More information about the R-help mailing list