[R] for (i in...)

From: Rina Oldager Miehs <rinamiehs_at_gmail.com>
Date: Sun, 9 Dec 2007 21:04:50 +0100


Hey

do anyone know why this error occurs??

> for(i in 1:n_trait){

+    for( j in 1:n_trait){
+    rG[i,j] <- (G_o[i,j]/(sqrt(G_o[i,i]%*%G_o[j,j]))
+    rP[i,j] <- (P_o[i,j]/(sqrt(P_o[i,i]%*%P_o[j,j]))
Error: unexpected symbol in:
" rG[i,j] <- (G_o[i,j]/(sqrt(G_o[i,i]%*%G_o[j,j]))

   rP"
> rE[i,j] <- (R_o[i,j]/(sqrt(R_o[i,i]%*%R_o[j,j]))
+ }
Error: unexpected '}' in:
" rE[i,j] <- (R_o[i,j]/(sqrt(R_o[i,i]%*%R_o[j,j]))

   }"
> h2[i] <- (G_o[i,i]/P_o[i,i])
> }

Error: unexpected '}' in "}"
>

If i make parentes around each of the commands this comes instead:

> for(i in 1:n_trait){

+    for( j in 1:n_trait){
+    (rG[i,j] <- (G_o[i,j]/(sqrt(G_o[i,i]%*%G_o[j,j])))
+    (rP[i,j] <- (P_o[i,j]/(sqrt(P_o[i,i]%*%P_o[j,j])))
+    (rE[i,j] <- (R_o[i,j]/(sqrt(R_o[i,i]%*%R_o[j,j])))
+    }

Error: unexpected '}' in:
" (rE[i,j] <- (R_o[i,j]/(sqrt(R_o[i,i]%*%R_o[j,j])))

   }"
> h2[i] <- (G_o[i,i]/P_o[i,i])
> }

Error: unexpected '}' in "}"
>

I dont understand what i am wrigthing wrong because i have a for command rigth before this one and that works...
> for (i in 1:n_trait){

+    for ( j in 1:n_trait){
+    R_o[i,j] = P_o[i,j]-G_o[i,j]
+    }
+ }

>

Is it because it is matrices??

Cincerely Rina

        [[alternative HTML version deleted]]



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. Received on Sun 09 Dec 2007 - 20:13:11 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 09 Dec 2007 - 21:30:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.