R/sl.match.comp.R

Defines functions sl.match.comp

Documented in sl.match.comp

sl.match.comp <-
function(x,table,comp.op="gt",offset=0) {
	if (comp.op == "gt") {
		for (i in (1+offset):length(table)) {
			if (table[i] > x) {return(i)}
		}
	} else if (comp.op == "lt") {
		for (i in (1+offset):length(table)) {
			if (table[i] < x) {return(i)}
		}
	} else if (comp.op == "get") {
		for (i in (1+offset):length(table)) {
			if (table[i] >= x) {return(i)}
		}
	} else if (comp.op == "let") {
		for (i in (1+offset):length(table)) {
			if (table[i] <= x) {return(i)}
		}
	} else if (comp.op == "eq") {   # this is equivalent to 'match'
		for (i in (1+offset):length(table)) {
			if (table[i] == x) {return(i)}
		}
	}
	warning("no match found")
	return(NA)
}
helgegoessling/spheRlab documentation built on April 8, 2024, 8:34 a.m.