(no subject)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

(no subject)

Tembe
Hello!

Is there anyone who can help me to this the error bellow? Ijust
started using R recently. Thank you


while sum(abs(Sb-D-Sc-t(Pi))>1E-5{Error: unexpected symbol in "while
sum">     >     k=K+1>     >     for(i in 1:nrow(c1)){+         +
   for(j in 1:ncol(c1)){+             +             if(Sb!=0){+
         +                 T2=D*T/Sa+                 +
}else {+                 +                 T2=0       +
 +             }+             +             Sc=sum(t(T))+
+             if(Sc!=0){+                 +
T3=Pi*T2/Sc+                 +             }else {+                 +
               T3=0+                 +             }+
Sb=sum(T)+             +         }+     }>     >     K[1] 0

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: (no subject)

Jeff Newmiller
I think you are missing a parenthesis around your condition [1][2].

For future reference:
a) You should post the code you ran as well as the error message... it is unusual for the error message alone to be enough to figure out the problem. In fact, try to make a "reproducible example" [3][4][5]... you will increase your chances of getting an answer.
b) Your message was garbled... in some cases this can completely obscure your question. You can prevent that from happening by setting your email program to create a plain text email whenever you post here.
c) Remember to put a subject line on your email.

[1] https://stat.ethz.ch/R-manual/R-devel/library/base/html/Control.html
[2] https://www-r--bloggers-com.cdn.ampproject.org/v/s/www.r-bloggers.com/control-structures-loops-in-r/
[3] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[4] http://adv-r.had.co.nz/Reproducibility.html

[5] https://cran.r-project.org/web/packages/reprex/index.html (read the vignette)


On July 15, 2018 6:25:43 AM PDT, Atanasio Alberto Tembe Tembe <[hidden email]> wrote:

>Hello!
>
>Is there anyone who can help me to this the error bellow? Ijust
>started using R recently. Thank you
>
>
>while sum(abs(Sb-D-Sc-t(Pi))>1E-5{Error: unexpected symbol in "while
>sum">     >     k=K+1>     >     for(i in 1:nrow(c1)){+         +
>   for(j in 1:ncol(c1)){+             +             if(Sb!=0){+
>         +                 T2=D*T/Sa+                 +
>}else {+                 +                 T2=0       +
> +             }+             +             Sc=sum(t(T))+
>+             if(Sc!=0){+                 +
>T3=Pi*T2/Sc+                 +             }else {+                 +
>               T3=0+                 +             }+
>Sb=sum(T)+             +         }+     }>     >     K[1] 0
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>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.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: (no subject)

Rui Barradas
In reply to this post by Tembe
Hello,

Please repost in plain text, NO HTML formating.

Also, you are missing an open parenthesis right after while:

while( sum(abs(Sb-D-Sc-t(Pi))>1E-5)){


Hope this helps,

Rui Barradas

Às 14:25 de 15-07-2018, Atanasio Alberto Tembe Tembe escreveu:

> Hello!
>
> Is there anyone who can help me to this the error bellow? Ijust
> started using R recently. Thank you
>
>
> while sum(abs(Sb-D-Sc-t(Pi))>1E-5{Error: unexpected symbol in "while
> sum">     >     k=K+1>     >     for(i in 1:nrow(c1)){+         +
>     for(j in 1:ncol(c1)){+             +             if(Sb!=0){+
>           +                 T2=D*T/Sa+                 +
> }else {+                 +                 T2=0       +
>   +             }+             +             Sc=sum(t(T))+
> +             if(Sc!=0){+                 +
> T3=Pi*T2/Sc+                 +             }else {+                 +
>                 T3=0+                 +             }+
> Sb=sum(T)+             +         }+     }>     >     K[1] 0
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: (no subject)

Rui Barradas
Hello,

Please always write to r-help, not to me personally, even if I was able
to be of assistance in the past.

As for your question, your code has several problems.

1) rowSums and colSums return vectors, not matrices. Even if they did,
see point 3) below.

2) You define K = 0 then in

X[1]=1/(K*A[i,j]*c[1,1]+K*A[i,j]*c[1,2]+K*A[i,j]*c[1,3])

the denominator is zero because A[i,j] and c[] are multiplied by it.

3) What are the i,j in A[i,j] and P[i,j]?


Hope this helps,

Rui Barradas


Às 11:51 de 21-07-2018, Atanasio Alberto Tembe Tembe escreveu:

> Dear Mr. Barradas,
>
> Thank you for your attention.
>
> Sorry for this personalized e-mail. I recently posted a query about
> while loop, but I did not get good feedback. I am a beginner in R and I
> wonder if you can me help again.
>
> If I have two matrices such as: a<-matrix(1:9,nrow=3,ncol=3) and
> c<-matrix(1:9,nrow=3,ncol=3).
>
> with defined variables:
> K=0
> A[i,j]=colSums(a)
> P[i,j]=rowSums(a)
> F[i,j]=c[i,j]^(-2 )
> X[i]=A[i,j]*c[i,j]
> X[j]=P[i,j]*c[i,j]
>
> How to perform the following calculation with while loop so that it
> stops when a convergence between X and Y values is reached?.
>
> X[1]=1/(K*A[i,j]*c[1,1]+K*A[i,j]*c[1,2]+K*A[i,j]*c[1,3])
>
> Y[1]=1/(X[1]*P[i,j]*c[1,1]+[X1]*P[i,j]*c[1,2]+[X1]*P[i,j]*c[1,3])
>
> X[2]=1/(Y[1]*A[i,j]*c[2,1]+Y[1]*A[i,j]*c[2,2]+Y[1]*A[i,j]*c[2,3])
>
> Y[2]=1/(X[2]*P[i,j]*c[2,1]+X[2]*P[i,j]*c[2,2]+X[2]*P[i,j]*c[2,3])
>
> X[3]=1/(Y[2]*A[i,j]*c[3,1]+Y[1]*A[i,j]*c[3,2]+Y[2]*A[i,j]*c[3,3])
>
> Y[3]=1/(X[3]*P[3]*c[3,1]+X[3]*P[3]*c[3,2]+X[3]*P[3]*c[3,3])
>
>
> Thank you very much.
>
>
>
>
>
>
>
>
>
>
> On Mon, Jul 16, 2018 at 6:51 PM, Atanasio Alberto Tembe Tembe
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Hi Mr. Barradas,
>
>     Thank you for your kind support. I will your suggestions.
>
>     Best regards
>     Tembe
>
>
>     On Mon, Jul 16, 2018 at 6:22 PM, Rui Barradas <[hidden email]
>     <mailto:[hidden email]>> wrote:
>
>         Hello,
>
>         Please repost in plain text, NO HTML formating.
>
>         Also, you are missing an open parenthesis right after while:
>
>         while( sum(abs(Sb-D-Sc-t(Pi))>1E-5)){
>
>
>         Hope this helps,
>
>         Rui Barradas
>
>
>         Às 14:25 de 15-07-2018, Atanasio Alberto Tembe Tembe escreveu:
>
>             Hello!
>
>             Is there anyone who can help me to this the error bellow? Ijust
>             started using R recently. Thank you
>
>
>             while sum(abs(Sb-D-Sc-t(Pi))>1E-5{Error: unexpected symbol
>             in "while
>             sum">     >     k=K+1>     >     for(i in 1:nrow(c1)){+    
>                 +
>                  for(j in 1:ncol(c1)){+             +          
>               if(Sb!=0){+
>                        +                 T2=D*T/Sa+                 +
>             }else {+                 +                 T2=0       +
>                +             }+             +             Sc=sum(t(T))+
>             +             if(Sc!=0){+                 +
>             T3=Pi*T2/Sc+                 +             }else {+        
>                     +
>                              T3=0+                 +             }+
>             Sb=sum(T)+             +         }+     }>     >     K[1] 0
>
>                      [[alternative HTML version deleted]]
>
>             ______________________________________________
>             [hidden email] <mailto:[hidden email]> mailing
>             list -- To UNSUBSCRIBE and more, see
>             https://stat.ethz.ch/mailman/listinfo/r-help
>             <https://stat.ethz.ch/mailman/listinfo/r-help>
>             PLEASE do read the posting guide
>             http://www.R-project.org/posting-guide.html
>             <http://www.R-project.org/posting-guide.html>
>             and provide commented, minimal, self-contained, reproducible
>             code.
>
>
>
>
>     --
>     Atanasio Alberto Tembe (Mr)
>     Doctoral student
>     Graduate School of Urban Innovation
>     Transportation and Urban Engineering Laboratory
>     Yokohama National University
>     Tel: +81-(0)80-4605-1305 <tel:+81%2080-8080-2482>
>       Mail: [hidden email]
>     <mailto:[hidden email]>
>     [hidden email] <mailto:[hidden email]>
>
>
>
>
> --
> Atanasio Alberto Tembe (Mr)
> Doctoral student
> Graduate School of Urban Innovation
> Transportation and Urban Engineering Laboratory
> Yokohama National University
> Tel: +81-(0)80-4605-1305 <tel:+81%2080-8080-2482>
>   Mail: [hidden email] <mailto:[hidden email]>
> [hidden email] <mailto:[hidden email]>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.