Hi guys, I am trying to write a function that allows me to perform specific transformations to each element of a 2 by 2 matrix to generate a 3 by 3 matrix.
Input into function-2 by 2 matrix Output from function -3 by 3 matrix For example: # a is my original 2 by 2 matrix #b is my new 3 by 3 matrix set.seed(2) a=matrix(rnorm(4),ncol=2) #let's say these are the transformations i wish to perform 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]) Thanks. Cheers, B -- View this message in context: http://r.789695.n4.nabble.com/specific-matrix-element-tranformation-tp4640550.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@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.