[R] specific matrix element tranformation
David Winsemius
dwinsemius at comcast.net
Fri Aug 17 08:36:35 CEST 2012
On Aug 16, 2012, at 8:39 PM, bantex wrote:
> Hi guys,
>
> After a long while I came up with this :
>
> set.seed(2)
> a<-matrix(rnorm(4),ncol=2)
> abc<-function(a)
> {
> b=matrix(NA,nrow=3,ncol=3)
> b[1,1]=a[1,1]+1
> b[1,2]=a[2,1]*a[2,2]
> b[1,3]=a[2,2]+a[1,1]
> b[2,1]=a[1,1]-5
> b[2,2]=sqrt(a[2,2])
> b[2,3]=a[1,1]/a[2,2]
> b[3,1]=a[2,2]-3
> b[3,2]=a[1,1]*(a[1,2]+a[2,2])
> b[3,3]=sqrt(a[1,1])/a[1,2]
>
> # return(b=matrix(c(b[1,1],b[1,2],b[1,3],b[2,1],b[2,2],b[2,3],
> # b[3,1],b[3,2],b[3,3]),ncol=3))
return(b)
> }
>
> How can I improve on it?
>
> Cheers,
> B
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/specific-matrix-element-tranformation-tp4640550p4640554.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
David Winsemius, MD
Alameda, CA, USA
More information about the R-help
mailing list