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.ra...@ouce.ox.ac.uk

______________________________________________
R-help@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.

Reply via email to