From: Muhammad Rahiz <muhammad.rahiz_at_ouce.ox.ac.uk>

Date: Tue, 26 Jan 2010 16:42:54 +0000

*{
*

in1[t+1] <-

ifelse(x1[t] < 0, (

}

R-help_at_r-project.org 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. Received on Tue 26 Jan 2010 - 16:44:56 GMT

Date: Tue, 26 Jan 2010 16:42:54 +0000

Dear all,

My script returns the following error:

Error in storage.mode(test) <- "logical" : (list) object cannot be coerced to type 'double'

I've looked around and some suggest that it could be the way data have been imported. For my case, I don't think it is such. Rather I think it has to be the way I define x1 and in1. x1 is an object in which the values are written to which in turn serve as input.

The object, x, contain 32 files of 2x2 matrix.

Any guidance would be appreciated.

Muhammad

# Cleans workspace

rm(list=ls())

**# ---------- DATA ---------- #
**
# Load DATA[1]: Monthly anomalies

f <- list.files("C:/Documents and Settings/shil3148/Desktop/dsi", "\\.txt$") # List files with pattern matching x <- lapply(f, read.table) # DATA[1]: Monthly anomalies

# Prepare DATA[2]: Rolling Sum

nt <- 6 ed <- nt - 1 fl <- length(x) y0 <- list() for (i in 1:(fl-ed)) # Remove NA values}

{

y0[[i]] <- Reduce("+", x[c(i:(i+ed))]) # RAW: Rolling Sum

# Data conversion

xx <- list()

for (z in 1:length(x))

*{
*

xx[[z]] <- as.matrix(x[[z]]) # convert data to matrix
}

yy <- list()

for (f in 1:length(y0))

*{
*

yy[[f]] <- as.matrix(y0[[f]]) # convert data to matrix
}

**# ---------- ALGORITHM ---------- #
**

x1 <- list() # Error here in1 <- list() # Error here for (t in 1:27) # This is the length of yy

in1[t+1] <-

ifelse(x1[t] < 0, (

ifelse(yy[t] < 0, x1[t] + xx[t+5], 0)), ( ifelse(yy[t+1] >= 0, 0, ( ifelse(xx[t+5] >= 0, 0, xx[t+5]) )) ) ) x1[t+1] <- in1[t+1]

}

R-help_at_r-project.org 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. Received on Tue 26 Jan 2010 - 16:44:56 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Tue 26 Jan 2010 - 17:10:13 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*