[R] for loop implementation in below problem

Goyani Zankrut z@nkrut20 @end|ng |rom gm@||@com
Sun Mar 21 17:55:56 CET 2021

I created custom function according to my requirement which is given below:

*selection.index<- function(ID, phen_mat, gen_mat, weight_mat, GAY){  ID =
toString(ID)  p<- as.matrix(phen_mat)  g<- as.matrix(gen_mat)  w<-
as.matrix(weight_mat)  bmat<- solve(phen_mat) %*% gen_mat %*% weight_mat
GA<- 2.063 * t(bmat) %*% g %*% w / (t(bmat) %*% p %*% bmat)^0.5  PRE<-
if(missing(GAY)){    (GA/GA) * 100  } else {    (GA/GAY) * 100  }  result<-
list("ID" = ID, "b" = matrix(round(bmat,4), nrow = 1), "GA" = round(GA,4),
"PRE" = round(PRE,4))  return(data.frame(result))}*

*sc<- list()*
*sc[[1]]<- selection.index(ID = 12, pmat[1:2,1:2], gmat[1:2,1:2],
*sc[[2]]<- selection.index(ID = 13, pmat[c(1,3),c(1,3)],
gmat[c(1,3),c(1,3)], wmat[c(1,3),1])*

for more detail about question follow stack overflow link:
*"Healthy soil, Healthy life."*
*"A war based on Satyagraha is always of two kinds. One is the war we wage
against injustice, and the other we fight our won weaknesses."* - *Sardar
*"You have to dream before your dreams can come true."* - *A. P. J.* *Abdul
*"Think before you print and save a tree."*

*B.Sc. (Hons.) Agriculture*

	[[alternative HTML version deleted]]

More information about the R-help mailing list