[Rodbcext-commits] r23 - in pkg/genutils: . R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jul 13 07:29:00 CEST 2012
Author: jaunario
Date: 2012-07-13 07:29:00 +0200 (Fri, 13 Jul 2012)
New Revision: 23
Modified:
pkg/genutils/DESCRIPTION
pkg/genutils/R/mathutils.r
Log:
Added in.range function
Modified: pkg/genutils/DESCRIPTION
===================================================================
--- pkg/genutils/DESCRIPTION 2012-05-30 00:59:05 UTC (rev 22)
+++ pkg/genutils/DESCRIPTION 2012-07-13 05:29:00 UTC (rev 23)
@@ -1,7 +1,7 @@
Package: genutils
Type: Package
Title: IRRI Geography Lab - General Utilities
-Version: 0.0.2
+Version: 0.0.3
Date: 2011-10-19
Depends: methods
Author: Jorrel Khalil S. Aunario
Modified: pkg/genutils/R/mathutils.r
===================================================================
--- pkg/genutils/R/mathutils.r 2012-05-30 00:59:05 UTC (rev 22)
+++ pkg/genutils/R/mathutils.r 2012-07-13 05:29:00 UTC (rev 23)
@@ -6,3 +6,17 @@
rescale <- function(x, oldmin, oldmax, newmin, newmax){
return((x-oldmin)*(newmax-newmin)/(oldmax-oldmin) + newmin)
}
+
+
+in.range <- function(x, minofrange, maxofrange, min.inc=TRUE, max.inc=TRUE){
+ if(minofrange>maxofrange){
+ temp <- minofrange
+ minofrange <- maxofrange
+ maxofrange <- temp
+ }
+ uop <- ifelse(max.inc, "<=", "<")
+ lop <- ifelse(min.inc, ">=", ">")
+
+ return(get(lop)(x,minofrange) & get(uop)(x, maxofrange))
+
+}
\ No newline at end of file
More information about the Rodbcext-commits
mailing list