Better(?):
The inequalities can be vectorized and rle() can then by apply()ed on the
rows:
(d is your data frame. "data' is a really bad name)
out <- d[,3:6] < d[,1] & d[,3:6]>d[,2]
a <- apply(as.matrix(out),1, rle)
a will be a list each component of which will have the consecutive runs
informat
Hello,
The following should be faster. It preallocates a vector of length nrows
instead of extending 'a' on every iteration.
a2 <- character(nrows)
for(b in 1:nrows)
{
c= ColChange(data[b,1],data[b,2],data[b,3:6],2)
a2[b]=c
}
all.equal(c(a), a2)
As for the use of apply, I'm g
Hi everyone,
I wonder if I can get your help using a custom function in apply.
Imagine the following dataframe called "data":
LowLim HighLim A1 A2 A3 A4
4 6 3 4 5 6
4 6 4 5 5
3 matches
Mail list logo