From: Unternährer Thomas, uth (uth@zhwin.ch)
Date: Wed 24 Dec 2003 - 19:34:41 EST
Message-id: <53A181E56FB0694ABFD212F8AEDA7F6F258A5F@langouste.zhwin.ch>
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@vcu.edu]
Gesendet: Mittwoch, 24. Dezember 2003 08:27
An: r-help@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@stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
This archive was generated by hypermail 2.1.3 : Thu 01 Jan 2004 - 09:21:00 EST