[R] Error: "non-numeric argument to binary operator"

Anil acharya acharya_anil at yahoo.com
Thu Jul 14 23:03:53 CEST 2011


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"); 

# 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" 


I appreciate if anyone can help me out. 
 Sincerely,

Anil Acharya 


More information about the R-help mailing list