Skip to content

I need help

3 messages · elyakhlifi mustapha, Duncan Murdoch, PIKAL Petr

#
On 02/05/2007 8:11 AM, elyakhlifi mustapha wrote:
R will parse a complete statement if you enter one.  Your if() was 
complete before the else was entered, so the else got orphaned.

The usual convention to avoid this is to put the else on the same line 
as the brace that closes the if, e.g.

if(na==1){
  ...
} else {
  ...
}

Duncan Murdoch
#
Hi
r-help-bounces at stat.math.ethz.ch napsal dne 02.05.2007 14:11:51:
write it
<-
c(donGeno[[k]][1:(pos-1)],donGeno[[k]][(pos+1):C(k)])}
c(donGeno[[k]][1:(pos-1)],donGeno[[k]][(pos+1):C(k)])}
c(donGeno[[k]][1:(pos-1)],donGeno[[k]][(pos+1):C(k)])}
c(donGeno[[k]][1:(pos-1)],donGeno[[k]][(pos+1):C(k)])}
What about to try to provide some reproducible example as suggested in 
posting guide. I believe your messy code can be evaluated in much more 
neat and concise way without so many ifs and fors. Maybe you can uncover 
some by yourself what trying to write a simple reproducible example. I am 
reluctant to decipher what you want to achieve but maybe you want retain 
only common values of several sets. So e.g. from match help page

## The intersection of two sets :
intersect <- function(x, y) y[match(x, y, nomatch = 0)]
[1] 39 87 66  7 64 79 62 98  6 95 96 35 74 36  3 50 58 97 52 33 61 88 47 
17 32 11 76 25
[1]  3  6  7 11 17 25 32 33 35 36 39 47 50

Regarding the error message
[1] 25
[1] 30
[1] 25
Error: syntax error, unexpected ELSE in "else"
In particular, you ***should not have a newline between } and else to 
avoid a syntax error*** in entering a if ... else construct at the 
keyboard or via source. For that reason, one 
(somewhat extreme) attitude of defensive programming is to always use 
braces, e.g., for if clauses

Regards
Petr
___________________________________________________________________________
http://www.R-project.org/posting-guide.html