[R] Select element out of several ncdf variables
confused
cstocker at climate.unibe.ch
Thu Jul 7 18:10:27 CEST 2011
Hi there
I'm working with ncdf data. I have different dataset for 4 runs, 4 seasons
and 3 timeslices (48 datasets in total). The datasets have the following
dimensions: 96 longitudes, 48 latitudes and 30 time steps. To read all of
them in, I wrote the following loop:
runs <- c("03","04","05","06")
years <- c(1851,1961,2061)
seasons <- c("DJF","MAM","JJA","SON")
for (i in runs) {
for (j in years) {
for (k in seasons) {
data <- open.ncdf(paste("/data09/cstocker/data/atm/tr_1500_",
i,"/PRECT/PREC_tr1500_", i,"_", j,"_", k,".nc", sep=""))
prect <- get.var.ncdf(data, "PRECT")
assign(paste("prec", k, j, i, sep="_"), prect)
}
}
}
I produced 48 variables called prec_DJF_1851_03 and so on..
Now, how can I select an element out of each of these variables?
If I have only one variable, I use: example[1:5, 6:10, 10:15]
...just as you would choose out of a simple array.
That I don't have to do it for every single variable by hand, I wanted to
create something like:
for (i in runs) {
for (j in years) {
for (k in seasons) {
assign(paste("newname", k, j, i, sep="_"), choose.element(paste("prec", k,
j, i, sep="_"), at.position(x,y,z)))
}
}
}
How can I solve this problem?
Took me already quite a lot of time to surf through all former posts.
Unfortunately I could't find what I was looking for. I'd be very thankful
for any kind of help as I am slowly very confused and frustrated...
cheers..
--
View this message in context: http://r.789695.n4.nabble.com/Select-element-out-of-several-ncdf-variables-tp3651945p3651945.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list