On 14.07.2011 23:03, Anil acharya wrote:> Hi
> I am posting in the topic related to the "non-numeric argument to
binary
> operator" as I got similar problem while running the netcdf code. I
have
> attached the file with this post. It is a climate data from NOAA site. The
code
> follows as:
>
> library(survival)
> library(RNetCDF)
> library(ncdf)
>
> setwd("c:/projects/netcdfcsfiles")
> Conn42 = open.ncdf("128.111.220.111.46.15.32.42.nc");
We do not have that file.
> # read the time variable, which measures years, and
> # use the length of the vector to estimate the time span
> #
> timeObj = get.var.ncdf(Conn42,"time");
> file42YrRangeDays = trunc(length(timeObj))
>
> # Process each file separately:
> # get attributes, read the rhum data cube,
> # extract the time series from the cube,
> # and rescale the time series vector
> #
> scaleFact = att.get.ncdf(Conn42,"rhum","scale_factor")
> offset = att.get.ncdf(Conn42,"rhum","add_offset")
> rhumObj = get.var.ncdf(Conn42,"rhum");
> #
> # the Relative Humidity data 'cube' has 4 dimensions:
> # latitudes (4), longitudes (3), pressure levels (1),
> # and time (days - several thousand)
> #
> rhCube = array(rhumObj,dim = c(4,3,file42YrRangeDays))
> rh42Vec = (((rhCube[2,2,1:file42YrRangeDays]) * scaleFact) + offset)
>
> #(Here is the point where I got the error "Error in (rhCube[2, 2,
> 1:file24YrRangeDays]) * scaleFact : non-numeric argument to binary
operator"
Since we do not have the data, we cannot know, but you really should
inspect
str(rhCube[2,2,1:file42YrRangeDays])
str(scaleFact)
if one or more of these are actually non-numeric.
Uwe Ligges
>
> I appreciate if anyone can help me out.
> Sincerely,
>
> Anil Acharya
>
>
>
> ______________________________________________
> R-help at 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.