Displaying 20 results from an estimated 78086 matches for "elses".
Did you mean:
else
2005 Nov 10
2
IF/Else
Hi,
I am trying to write a for loop with if else statements to calculate
biomass density estimates for different types of sampling gear.
My code is:
bmd=for (i in 1:length(Gear)){
if (Gear==20) {bioden=Biomass/141}
else {if (Gear==23) {bioden=Biomass/68}}
else {if (Gear==160) {bioden=Biomass/4120}}
else {if (Gear==170) {bioden=Biomass/2210}}
else {if (Gear==300)
2011 Nov 15
3
if/else scope
What is wrong with the following?
x <- 1:2
if(x[1] > 0)
{
if(x[2] > 0)
{
print("1 & 2 > 0")
}
else
{
print("1 > 0")
}
}
else
{
if(x[2] > 0)
{
2008 Jun 05
5
vector comparison
I know this is fairly basic, but I must have somehow missed it in the
manuals.
I have two vectors, often of unequal length. I would like to compare
them for identity. Order of elements do not matter, but they should
contain the same.
I.e: I want this kind of comparison:
> if (1==1) show("yes") else show("blah")
[1] "yes"
> if (1==2) show("yes") else
2010 Feb 22
3
gsub patterns from vector elements w/out loop?
Dear list,
I have two vectors:
x <- c("one","two")
y <- paste(rep(x,2),"blah")
I want to replace all occurrences of each element of x in y with
something else, so that y looks like this:
y
[1] "something else blah" "something else blah" "something else blah"
[4] "something else blah"
I can do this using a loop:
for (
2010 Feb 15
1
argh .. if/else .. why?
Hello, would someone please help explain the following inconsistency
in the if/else statement to me?
The format of the if/else #3 below is ok, but if/else #1 is not? (I get
an "unexpected else" type error.) In order for it to work I have to use
if/else #2
Thanks .. maybe there is some reason for this, but this looks very
inconsistent to me.
R version 2.10.1 (2009-12-14)
Ubuntu 9.04
2012 Jan 22
2
if/else statement without curly brackets gives a problem
Hello,
This example seems strange to me:
> if (2 > 3) print('Yes'); else print('No')
Error: unexpected 'else' in " else"
> {if (2 > 3) print('Yes'); else print('No')}
Error: unexpected 'else' in "{if (2 > 3) print('Yes'); else"
> {
+ if (2 > 3) print('no')
+ else print('yes')
+ }
2010 Sep 14
4
If then else with command for
Hey listers,
I am trying to do something simple... Check the program below...
I would like to create a variable named COLOR according to the conditions
that I stablished... But the problem is that it seems that my variable COLOR
is checking just on sample, may be last in the loop... Certainly, I am
missing something...
Thanks in advance,
Marcio
2009 Nov 13
4
Simple if else statement problem
Hello, I am getting an error with the following code:
if( P2 > P1)
+ {
+ P<-P2
+ }
> else
Erro: unexpected 'else' in "else"
> {
+ P<-P1
+ }
I checked the syntax so I don?t understand, I have other if else statements
with the same syntax working. Thanks in advance
--
View this message in context:
2007 May 16
2
use mathematics formula
hello,
I wanna use some mathematics formula and to do this I tried several way in paricular using
strsplit
textconnection
scan
setdiff
but I think that it's a lil hard
the data frame that I'm working on is as follow
> donCalcara2
Id_Cara Form_C
1 743
2007 Mar 06
2
parse error with if else (PR#9551)
Full_Name: Stephanie MAHEVAS
Version: 2.4.1
OS: Windows NT
Submission from: (NULL) (134.246.55.50)
the two following instructions provide a synthax error :
if ( 5 > 4 ) cat("ok1")
else cat("ok2")
and
if ( 5 > 4 ){ cat("ok1")}
else cat("ok2")
whereas these ones don't
if ( 5 > 4 ) cat("ok1") else cat("ok2")
and
if (
2009 Mar 09
0
Crash when reloading AEL
Hello list,
I have this strange problem whenever I try to make an "ael reload" from the
Asterisk CLI. The command gives the following result and crashes:
voip-1*CLI> ael reload
Disconnected from Asterisk server
Executing last minute cleanups
Asterisk ending (0).
root at voip-1:/etc/asterisk#
As far as I can see, aelparse can't find any errors in my configuration,
following
2007 Jun 20
4
Got "Unexpected ELSE error"
Dear R-users,
I have a problem with the IF-ELSE syntax.
Please look at the folllowing code and tell me what's wrong:
a <- TRUE
if ( a )
{
cat("TRUE","\n")
}
else
{
cat("FALSE","\n")
}
If I try to execute with R I get:
Error: syntax error, unexpected ELSE in "else"
The strange thing is either "cat"
2003 Feb 11
4
How "else" works
I have what is likely to be a simple question about the else keyword.
The usage in the help pages is as follows:
if(cond) cons.expr else alt.expr
I would expect to be able to use it in the following way as well:
if(cond){
cons.expr
}
else alt.expr
This results a syntax error.
Am I doing something wrong, or doesn't R support the spanning of the
combination of if and else
2005 Sep 13
11
if() command
Hi everyone !
Could you please help me with this problem ?
I??ve trying to write a code that assign to a variable the content from
another, but all I??ve got is a message error. For example:
if (age <=10) {group == 1}
else if (age > 10 & age <= 20) {group == 2}
else {group == 3}
Syntax error
Or
if (age <=10) {group == 1}
else (age > 10 & age <= 20) {group == 2}
2011 Jul 25
1
Problem with random number simulation
Hi this is my first post. I am trying to run a simulation for a computer
playing Von Neumann poker and adjusting it's expectation of an opponent's
behavior according to how the opponent plays. This program involves random
generation of "hands" and shifting of parameters. However, when I run the
code, no errors come up, but the program doesn't do anything. Could someone
2009 Feb 24
1
R parser for If-else
Hi list,
I don't know if somebody has spent a lot of time debugging strange
problems with if else positioning - the parser seems to recognize only
the syntax bellow - this is the only way of making these pieces of
code to work.
As far as i'm concerned, no examples were available (it would be so
awesome to have them in the introductory manual!)
#Try to change the placement of the
2011 Jan 26
2
applying a set of rules to each row
All,
I would like to apply a set of rules to each row of the sample data set
below. The rule sets are the guidelines for determining an individual's
date for retirement eligibility. The rules are found in this document,
http://www.opm.gov/feddata/RetirementPaperFinal_v4.pdf. I am only
interested in the top two categories for retirement eligibility, the
CSRS and FERS plans.
The data set has
2009 Oct 03
3
else if statement error
Hello,
I am doing a simple if else statement in R. But it always comes out error
such as 'unexpected error'
There are two variables. ini and b. when ini=1, a=3; when ini>1 and b>2,
a=5; all other situations, a=6. I don't know where it is wrong.
Here is my code
ini=3
b=4
if (ini==1) {
a=3
}
else if (ini>1 and b>2 ) {
a=5
}
else {a=6}
Thanks a
2003 Nov 13
4
Problem with parser and if/else
Dear r-help people,
could you confirm that this is correct behaviour for R? I am using RH9.
the code:
x1 <- 1:6
t1 <- 5
if (length(x1) >= t1) {
cat("in the if \n")
} else {
cat("in the else\n")
}
runs fine:
> source("test_if_else.R")
in the if
>
but the code:
x1 <- 1:6
t1 <- 5
if (length(x1) >= t1) {
cat("in the if 2\n")
}
2007 May 02
2
I need help
hello,
I need help because I don't understand the syntaxe "else" how can I write it for example I writed a script to cut missings values and I have errors
> if(na==length(C)){
+ pos=match(0,match(donGeno[[na-1]],donGeno[[na]],nomatch=0))
+ for(k in 1:(na-1)) {
+ if(pos==1) {donGeno[[k]] <-