Thanks Barry for the clarification.
With regards to the following;
d2[[i]] <- file[[i]] - mean
renamed to
d2[[i]] <- f[[i]] - m
The object f contains the following so clearly f is subsettable
[[1]]
V1
1 10
2 10
3 10
[[2]]
V1
1 11
2 11
3 11
[[3]]
V1
1 12
2 12
3 12
My plan is to subtract m from each subset of f and to store the output
as each individual subsets. So,
output1 <- f[[1]] - m
output2 <- f[[2]] - m
output3 <- f[[3]] - m
If I run the following to achieve the desired result, there is an error
as written in the subject heading.
d2[[i]] <- f[[i]] - m
If I run the following, the error is gone but I'm not getting the output for
each individual file I require
d2 <- f[[i]] - m
The issue is, how do I make d2 subsettable?
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: [email protected]
Barry Rowlingson wrote:
On Sun, Dec 20, 2009 at 7:40 PM, Muhammad Rahiz
<[email protected]> wrote:
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
No it doesn't. It copies the object called 'file' into an object
called 'd2'. What's the object called 'file'? If you've not created
one already, its the 'file' function that R uses to read stuff from
files. So when you do:
d2[[i]] <- file[[i]] - mean
you are trying to subset from d2 (and from 'file'). If I do this:
> file[[2]]
I get your error message:
Error in file[[2]] : object of type 'closure' is not subsettable
So clearly you aren't doing what you think you're doing.
Some hints:
1. Read a good introduction to R. You are making a number of
fundamental mistakes here.
2. Run each line separately and check what value you get back by printing it.
3. Don't give your objects the same name as R functions (you're using
'seq', 'file', and 'mean'). Although this may work, it will confuse
people later...
Barry
______________________________________________
[email protected] 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.