# Re: [R] How to know the row number of raw matrix after resampling?

From: Gabor Grothendieck (ggrothendieck@myway.com)
Date: Thu 13 May 2004 - 02:36:32 EST

```Message-id: <loom.20040512T183208-797@post.gmane.org>

```

For your first question the simplest way to handle it is to
sample the indices rather than the data. For example,

x <- seq(10,200,10) # data
ix <- sample(length(x),10,rep=T) # 10 samples from 1:length(x)
s <- x[ix] # samples

Now ix has the indices of s.

Taemyong Choi <tmchoi <at> ris.chonnam.ac.kr> writes:

:
: > DATA
:
: [,1]
:
: [1,] -2.0314185
:
: [2,] -0.3594015
:
: [3,] -1.3225832
:
: [4,] 1.5050892
:
: [5,] -0.4535558
:
: [6,] 3.6335036
:
: [7,] 5.1965750
:
: [8,] 4.2923129
:
: [9,] 6.0913187
:
: [10,] 4.9131070
:
: > RESA
:
: [,1] [,2] [,3] [,4] [,5]
:
: [1,] -2.0314185 1.5050892 -1.3225832 -1.3225832 -2.0314185
:
: [2,] -0.3594015 -0.3594015 4.2923129 -0.3594015 -0.4535558
:
: [3,] 4.9131070 4.9131070 -2.0314185 4.9131070 3.6335036
:
: [4,] 3.6335036 -0.4535558 3.6335036 1.5050892 -0.3594015
:
: [5,] 1.5050892 6.0913187 -0.3594015 4.2923129 6.0913187
:
: [6,] 6.0913187 3.6335036 5.1965750 -2.0314185 5.1965750
:
: [7,] -0.4535558 5.1965750 6.0913187 3.6335036 4.9131070
:
: First,
:
: RESA matrix consists of resampling DATA matrix. I would like to know the row
: number of RESA matrix's value in DATA matrix.
:
: For example, RESA[1,1] = -2.0314185 and its row number in DATA matrix is 1.
:
: RESA[1,3]=4.9131070 and its row number in DATA matrix is
: 10.
:
: Is there a simple way to know the row number?
:
: I
:
: > clus
:
: col1 col2 col3 col4 col5
:
: [1,] 1 1 1 1 1
:
: [2,] 2 2 0 2 1
:
: [3,] 2 1 1 2 2
:
: [4,] 1 2 2 1 2
:
: [5,] 3 1 2 2 3
:
: [6,] 3 3 0 3 2
:
: [7,] 1 3 2 0 0
:
: Second, I want to count columns of each row without 0
:
: i.e. The number of clus[2,]'s columns is 4.
:
: I solve this with next code.
:
: number <- c(rep(1,5)) # 5 is total column number.
:
: sum(number[clus[2,]!=0])
:
: Is there more simple method?
:
: Finally, clus[2,]'s mode is 2. I try to find function to know mode, but I
: have failed.
:
: What's the function to know mode?
:
: [[alternative HTML version deleted]]
:
: ______________________________________________
: R-help <at> stat.math.ethz.ch mailing list
: https://www.stat.math.ethz.ch/mailman/listinfo/r-help