X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=R%2Fvec_bin.R;h=27f771bfc1963e75a0ba374ed517b0c34180c1d0;hb=9ade3f1b66fa07ad9f1a3b09fc05462c783841de;hp=01dbfe160da07e2b89941499d0473fd755c892ea;hpb=d1531659214edd6eaef0ac9ec835455614bba16c;p=valse.git diff --git a/R/vec_bin.R b/R/vec_bin.R index 01dbfe1..27f771b 100644 --- a/R/vec_bin.R +++ b/R/vec_bin.R @@ -6,18 +6,18 @@ #' @return a list with Z (a binary vector of size the size of X) and indices where Z is equal to 1 vec_bin = function(X,r) { - Z = rep(0,length(X)) - indice = c() - j = 1 - for (i in 1:length(X)) - { - if(X[i] == r) - { - Z[i] = 1 - indice[j] = i - j=j+1 - } else - Z[i] = 0 - } - return (list(Z=Z,indice=indice)) -} \ No newline at end of file + Z = rep(0,length(X)) + indice = c() + j = 1 + for (i in 1:length(X)) + { + if(X[i] == r) + { + Z[i] = 1 + indice[j] = i + j=j+1 + } else + Z[i] = 0 + } + return (list(Z=Z,indice=indice)) +}