revert src/test/utils.c
[valse.git] / R / vec_bin.R
... / ...
CommitLineData
1#' A function needed in initSmallEM
2#'
3#' @param X vector with integer values
4#' @param r integer
5#'
6#' @return a list with Z (a binary vector of size the size of X) and indices where Z is equal to 1
7vec_bin = function(X,r)
8{
9 Z = rep(0,length(X))
10 indice = c()
11 j = 1
12 for (i in 1:length(X))
13 {
14 if(X[i] == r)
15 {
16 Z[i] = 1
17 indice[j] = i
18 j=j+1
19 } else
20 Z[i] = 0
21 }
22 return (list(Z=Z,indice=indice))
23}