Your syntax is wrong; e.g.,
if i==j

should be

if (i == j)

same with your use of 'if else'.  You need to use the correct syntax.
Your example is hard to follow without the correct indentation since
you are using the incorrect syntax.

On 8/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi friends,
> I would like to construct a matrix of seasonal dummies with number of rows 
> (observations)=100. such matrix is written as follows:[1 0 0 0;0 1 0 0;0 0 1 
> 0;0 0 0 1;1 0 0 0;0 1 0 0;0 0 1 0;0 0 0 1;etc...] . I wrote the following 
> program:
> T=100
> br=matrix(0,T,4)
> {
> for (i in 1:T)
> for (j in 1:4)
> if i==j
> br[i,j]=1
> if else (abs(i-j)%%4==0
> br[i,j]=1
> else
> br[i,j]=0
> }
> z<-br
> z
>
> but unfortunately I obtained from the console the following message:
> > {
> + for (i in 1:T)
> +      for (j in 1:4)
> +         (if i==j)
> Erreur : syntax error, unexpected SYMBOL, expecting '(' dans :
> "
> "
> >             br[i,j]=1
> Erreur dans br[i, j] = 1 : objet "i" non trouvé
> >
> >         (if else (abs(i-j)%%4==0)
> Erreur : syntax error, unexpected ELSE, expecting '(' dans "        (if else"
> >             br[i,j]=1
> Erreur dans br[i, j] = 1 : objet "i" non trouvé
> >         else
> Erreur : syntax error, unexpected ELSE dans "        else"
> >             br[i,j]=0
> Erreur dans br[i, j] = 0 : objet "i" non trouvé
> >               }
> Erreur : syntax error, unexpected '}' dans "              }"
> >
> Can you please rectify my smal program, I tried to rectify it but I can't. 
> Many thanks in advance.
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to