Displaying 2 results from an estimated 2 matches for "ukcp09".
Did you mean:
uk209
2009 Dec 20
1
Problem with sequence in loop
....
I've used seq() to create the increment
seq <- paste(seq(1914, 2006, by=1), "*.txt.h", sep=".")
But it didn't work.
Below is the script;
seq <- paste(seq(1914, 2006, by=1), "*.txt", sep=".")
for (i in 1:93){
list <- list.files("~/ukcp09/txt/x.djf", seq)
file <- lapply(list, read.table)
mean <- (Reduce("+", file))/3
}
When I call
> objects()
> list
[1] "2006.01.txt.h" "2006.02.txt.h" "2006.12.txt.h"
The listed files are the last files in the sequence.
Am I doing the lo...
2009 Dec 20
3
Object of type 'closure' not subsettable
...'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 fol...