My problem is as follows: i is a list of integers of variable length. Now I want to compute a new vector/array that contains 1's at the positions indicated in i. For example: c(2, 4) -> c(0, 1, 0, 1)
Using something like i = i - c(0, i[2:length(i) - 1]); sapply(i, function(x) c(rep(0, x - 1), 1))); faces me with the problem of concatenating the result, which I could somehow not find a solution for. Thank you very much in advance. Stefan ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html