Error symbol in function

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Error symbol in function

snov
This post has NOT been accepted by the mailing list yet.
Please help me with this function I get an error at the beginning, it is used to make a grid, is there a more simple way?

regular_grid_L8 = function(L8_im, rlon, rlat, nx, ny) {
 
  ## read file  
#  load(f)
  x <- L8_im
 
  ## extract ROI1
  ok <- (x$lon >= rlon[1]rm) & (x$lon <= rlon[2]) &
(x$lat >= rlat[1]) & (x$lat <= rlat[2])
 
  xx <- x[ok, ]
 
  ## select parameter
  y <- xx[ ,(1:ncol(x))[names(x) == "spm"]]
 
  ## define grid interval
  dx   <- seq(rlon[1], rlon[2],, nx)
  dy   <- seq(rlat[1], rlat[2],, ny)
 
  ## divides the range of xx into intervals and codes the values
  ## in xx according to which interval they fall.
  fx  <- cut(xx$lon, dx)
  fy  <- cut(xx$lat, breaks = dy)
  z   <- tapply(y, list(fx, fy), mean, na.rm = TRUE)
  ddx <- 0.5 * (dx[-1] + dx[-length(dx)])
  ddy <- 0.5 * (dy[-1] + dy[-length(dy)])
 
  ## return result
  list(x = ddx, y = ddy, z = z)
}

-----Error-----
+   ok <- (x$lon >= rlon[1]rm) & (x$lon <= rlon[2]) &
Error: unexpected symbol in:
"  ## extract ROI1
  ok <- (x$lon >= rlon[1]rm"