AW: [R] coding logic and syntax in R
"Unternährer Thomas, uth"
uth at zhwin.ch
Wed Dec 24 09:34:41 CET 2003
Hi,
In <- as.numeric(strsplit("11111011111101111111111111111111", "")[[1]])
Sets <- rep(letters[1:4], each = 8) ## your sets
Sp.In <- split(In, Sets)
logical <- sapply(Sp.In, function(x) any(x == 0))
c(as.matrix(data.frame(Sp.In))* rep(!logical, each = 8)) ## for equal sets
This could give you a hint
Thomas
-----Ursprüngliche Nachricht-----
Von: Pravin [mailto:jadhavpr at vcu.edu]
Gesendet: Mittwoch, 24. Dezember 2003 08:27
An: r-help at stat.math.ethz.ch
Betreff: [R] coding logic and syntax in R
Hello,
I am a beginner in R programming and recently heard about this mailing list. Currently, I am trapped into a simple problem for which I just can't find a solution. I have a huge dataset (~81,000 observations) that has been analyzed and the final result is in the form of 0 and 1(one column).
I need to write a code to process this column in a little complicated way.
These 81,000 observations are actually 9,000 sets (81,000/9).
So, in each set whenever zero appears, rest all observations become zero.
For example;
If the column has:
111110111111011111111111111111111....
The output should look like:
111110000111000000111111111111111...
I hope this makes sense.
Thank you in anticipation,
Pravin
Pravin Jadhav
[[alternative HTML version deleted]]
______________________________________________
R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
More information about the R-help
mailing list