Skip to content
Back to formatted view

Raw Message

Message-ID: <VI1PR02MB11990DEBC0EB0054120C6B3A881E0@VI1PR02MB1199.eurprd02.prod.outlook.com>
Date: 2016-08-11T20:24:38Z
From: Steve Murray
Subject: Conditional Execution Error

Dear all,


Please could someone explain why 'Version 1' of the code below works, but 'Version 2' produces an error (albeit following the correct output)?


#Version 1

h <- 10
j <- -5

if(h < j) {
print("statement is true")
} else {
while (h >= j) {
print(h)
h <- h - 1
}
}


#Version 2

h <- 10
j <- -5

ifelse(h < j, "statement is true", while(h >= j) {
print(h)
h <- h - 1
}
)



If anyone has an explanation and solution (for avoiding the error), then I'd be pleased to hear it.


Many thanks,

Steve


	[[alternative HTML version deleted]]