[R] Did something big change in 1.5?
Thomas Lumley
tlumley at u.washington.edu
Mon May 6 20:46:19 CEST 2002
On 6 May 2002, Stuart Luppescu wrote:
> I can't remember the programming term -- ``implicit declaration''? Has
> this changed between 1.4.1 and 1.5? This code used to run as is:
>
> for (i in 1:length(diff.time)) {
> if (diff.time[i] < 16) {
> total.time[i] <- ifelse(i==1, 7.5, total.time[i-1]) + diff.time[i]
> last.time[i] <- 0
> }
> else {
> total.time[i] <- 7.5
> last.time[i-1] <- 1
> }
> }
>
> Now in 1.5 I get messages saying, Object "total.time" not found. (Same
> thing for last.time, as well.) However, if I include
> total.time <- NA
> last.time <- NA
> before this piece of code, it runs fine. Why should this be?
Because ifelse() evaluates both its arguments, and the second one isn't
defined. You mean
total.time[i]<-(if (i==1) 7.5 else total.time[i-1]) +diff.time[i]
or similar.
The code gives the error
Error: Object "total.time" not found
for me on R1.4.1. Perhaps you used to have a total.time object lying
around in your workspace?
-thomas
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list