[R] calculate monthly mean
Ali Alsamawi
ali.alsamawi at unsw.edu.au
Fri Sep 3 02:06:41 CEST 2010
Hello group
Im trying to plot 3d with scatterplot packages, i got error say " length(color) must be equal length(x) or 1 " may data has dimensions (lon,lat,lev,time) ,the time in month i want to
calculate the monthly mean for the time how can i make that , is there any function doing that
Thanks a lot
##load rgl package
library(rgl)
library(fields)
library(ncdf)
library(scatterplot3d)
## open binary file to read
nc <- open.ncdf("/srv/ccrc/data05/z3236814/mm5/co2/2000/q.200001.mon.nc")
v1 <- nc$var [[1]]
v2 <- nc$var [[2]]
v3 <- nc$var [[3]]
data1 <- get.var.ncdf(nc,v1)
data2 <- get.var.ncdf(nc,v2)
data3 <- get.var.ncdf(nc,v3)
coldat = data1[1:111,1:101,23,1:60]
## creat colour
hcol = cumsum(coldat)
coldat = hcol
hcol = hcol/max(hcol,na.rm=TRUE)
col <- hsv(h=hcol,s=1,v=1)
X <-scatterplot3d(data3[1:111,1:101],data2[1:111,1:101],data1[1:111,1:101,23,1:60],color=col)
More information about the R-help
mailing list