Stavros Macrakis wrote:
On Wed, Dec 31, 2008 at 12:44 PM, Guillaume Chapron
carnivorescie...@gmail.com wrote:
m[-sample(which(m[,1]8 m[,2]12),2),]
Supposing I sample only one row among the ones matching my criteria. Then
consider the case where there is just one row matching this
On 02/01/2009 10:07 AM, Wacek Kusnierczyk wrote:
Stavros Macrakis wrote:
On Wed, Dec 31, 2008 at 12:44 PM, Guillaume Chapron
carnivorescie...@gmail.com wrote:
m[-sample(which(m[,1]8 m[,2]12),2),]
Supposing I sample only one row among the ones matching my criteria. Then
consider the
xxx wrote:
On Fri, Jan 2, 2009 at 10:07 AM, Wacek Kusnierczyk
waclaw.marcin.kusnierc...@idi.ntnu.no wrote:
... 'sample' takes a sample of the specified size from the elements of
'x' using either with or without replacement.
x: Either a (numeric, complex, character or
There is another undocumented glitch in sample:
sample(2^31-1,1) = OK
sample(2^31 ,1) = Error
I suppose you could interpret sampling takes place from '1:x' to
mean that 1:x is actually generated, but that doesn't work as an
explanation either; on my 32-bit Windows box, 1:(2^29) gives
I believe this does what you want:
m[-sample(which(m[,1]8 m[,2]12),2),]
Analysis:
Get a boolean vector of rows fitting criteria:
m[,1]8 m[,2]12
What are their indexes?
which(...)
Choose two among those indexes:
sample(...,2)
Thanks, but this does not seem to always work.
On Wed, 31 Dec 2008, Guillaume Chapron wrote:
I believe this does what you want:
m[-sample(which(m[,1]8 m[,2]12),2),]
Analysis:
Get a boolean vector of rows fitting criteria:
m[,1]8 m[,2]12
What are their indexes?
which(...)
Choose two among those indexes:
sample(...,2)
On Wed, Dec 31, 2008 at 12:44 PM, Guillaume Chapron
carnivorescie...@gmail.com wrote:
m[-sample(which(m[,1]8 m[,2]12),2),]
Supposing I sample only one row among the ones matching my criteria. Then
consider the case where there is just one row matching this criteria. Sure,
there is no need to
Hello all,
I create the following matrix:
m - matrix(1:20, nrow = 10, ncol = 2)
which looks like:
[,1] [,2]
[1,]1 11
[2,]2 12
[3,]3 13
[4,]4 14
[5,]5 15
[6,]6 16
[7,]7 17
[8,]8 18
[9,]9 19
[10,] 10 20
Then, I want to
Assuming your values aren't always in such neat order, you could use
something like:
valtoremove1 - sample((1:nrow(m))[m[,1] 8], 1)
valtoremove2 - sample((1:nrow(m))[m[,1] 12], 1)
Sarah
On Tue, Dec 30, 2008 at 9:59 AM, Guillaume Chapron
carnivorescie...@gmail.com wrote:
Hello all,
I create
Hi,
The approach below uses a function. The nice thing about it is that you can
define the cutoff values dynamically (i.e. what is 8 and 12 in your
example). The functions extract a row index to remove. Be aware that there
is no warning if both return the same row index. You might have to adjust
I believe this does what you want:
m[-sample(which(m[,1]8 m[,2]12),2),]
Analysis:
Get a boolean vector of rows fitting criteria:
m[,1]8 m[,2]12
What are their indexes?
which(...)
Choose two among those indexes:
sample(...,2)
Choose all except the selected rows from the
11 matches
Mail list logo