A one-dimensional delete might be faster:
n - 4000
m - 0.01
matr - matrix(1:(n^2), n, n)
excl_r - sample(n, m*n)
incl_r - setdiff(1:n, excl_r)
excl_c - sample(n, m*n)
incl_c - setdiff(1:n, excl_c)
system.time(matr[-excl_r, -excl_c])
system.time(
{ m4 - matr[outer(incl_r, incl_c, function(i, j) i
Yes, consider:
df=data.frame(Clinic=rep(c(A, B, C), 2),
Rep=c(1, 1, 1, 2, 2, 2),
colM1=c(1, 0, 0, 1, -1, 1),
ColM2=c(0, -1, -1, 1, 0, 0),
ColM3=c(0, 0, 1, -1, 0, 1),
ColM40=c(1, 0, -1, 0, 1, -1)
)
Clinic=1; Rep=2
Consider
na=43; nb=5; x=1:na
ns=rep(na %/% nb, nb) + (1:nb = na %% nb)
split(x, rep(1:nb, ns))
Heikki Kaskelma
On Fri, 2 Feb 2007, jim holtman [EMAIL PROTECTED] wrote:
This might do what you want:
# test data
x - 1:43
nb - 5 # number of subsets
# create vector of lengths of subsets
ns -
Given a series of observations, I want to know how many consecutive
past
observations are below the last one.
prune=function(m)
{ mr=rev(m)
ms=cumsum(mr mr[1])
sum(seq_along(ms) - ms == 1) - 1
}
prune(c(3, 4, 10, 14, 8, 3, 4, 8, 9)) # 4
prune(c(3, 4, 10, 14, 8, 3, 4, 11, 9)) # 0
Heikki
idx = c(31, 36, 41, 61, 66, 71, 91, 96, 101, 121, 126, 131)
temp = 1:150
res = temp[idx]
dim(res) = c(3, length(res) %/% 3)
res = t(rbind(res, res[2, ] - res[1, ], res[3, ] - res[2, ]))
res
Heikki Kaskelma
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of