Skip to content

Instantly share code, notes, and snippets.

@kokkytos
Created November 27, 2019 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kokkytos/ca2c319134677b19900579665267a7a7 to your computer and use it in GitHub Desktop.
Save kokkytos/ca2c319134677b19900579665267a7a7 to your computer and use it in GitHub Desktop.
--- stackApply.R 2019-11-27 09:12:08.000000000 +0200
+++ /home/leonidas/Desktop/raster_source/source/R/stackApply.R 2019-11-27 12:50:43.268272464 +0200
@@ -84,9 +84,9 @@
}
if (rowcalc) {
- v <- lapply(uin, function(i) fun(a[, ind==uin[i], drop=FALSE], na.rm=na.rm))
+ v <- lapply(uin, function(i) fun(a[, ind==i, drop=FALSE], na.rm=na.rm))
} else {
- v <- lapply(uin, function(i, ...) apply(a[, ind==uin[i], drop=FALSE], 1, fun, na.rm=na.rm))
+ v <- lapply(uin, function(i, ...) apply(a[, ind==i, drop=FALSE], 1, fun, na.rm=na.rm))
}
v <- do.call(cbind, v)
out <- writeValues(out, v, tr$row[i])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment