[R] Object of type 'closure' not subsettable

Muhammad Rahiz muhammad.rahiz at ouce.ox.ac.uk
Sun Dec 20 20:40:34 CET 2009


Hi all,

How can I overcome the error "object of type 'closure' not subsettable"

I ran the following script
seq <- paste(seq(1914, 1916, by=1), "*.y", sep=".") # make sequence
c <- 3 # total number of files
d2 <- file # creates dummy file

# Input sequence in loop
for (i in 1:3){
list <- list.files("~/ukcp09/txt/x.djf", seq[[i]])
file <- lapply(list, read.table)

# Calculations
mean <- (Reduce("+", file))/c
d2[[i]] <- file[[i]] - mean

Apparently, the following command is the source of the error.

d2[[i]] <- file[[i]] - mean

It works OK when I typed into the terminal the following after running 
the script.

 > for (j in 1:3) print (file[[j]]-mean)


Thanks.

Muhammad

-- 
Muhammad Rahiz  |  Doctoral Student in Regional Climate Modeling					
Climate Research Laboratory, School of Geography & the Environment	
Oxford University Centre for the Environment
South Parks Road, Oxford, OX1 3QY, United Kingdom 
Tel: +44 (0)1865-285194	 Mobile: +44 (0)7854-625974
Email: muhammad.rahiz at ouce.ox.ac.uk




More information about the R-help mailing list