Have a look at ?cumsum. Apply that on a true/false vector (p-value >
0.05)
------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium
Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be
www.inbo.be
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data.
~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey
> -----Oorspronkelijk bericht-----
> Van: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] Namens jd6688
> Verzonden: maandag 26 juli 2010 7:07
> Aan: r-help at r-project.org
> Onderwerp: [R] data arranged by p-values
>
>
> Id cat1 location item_values p-values
> sequence
> a111 1 3002737 0.196504377 0.01 1
> a112 1 3017821 0.196504377 0.05 2
> a113 1 3027730 0.196504377 0.02 3
> a114 1 3036220 0.196504377 0.04 4
> a115 1 3053984 0.196504377 0.03 5
> a116 1 3063892 0.196504377 0.07 6
> a117 1 3076333 0.196504377 0.08 7
> a118 1 3090500 0.196504377 0.02 8
> a119 1 3103304 0.196504377 0.03 9
> a120 1 3119350 0.196504377 0.05 10
> a121 1 3129884 0.196504377 0.01 11
> a122 1 3154598 0.196504377 0.03 12
> a123 1 3170910 0.196504377 0.05 13
> a124 1 3180712 0.196504377 0.06 14
> a125 1 3186519 0.196504377 0.07 15
> a126 1 3192256 0.196504377 0.09 16
> a127 1 3198441 0.196504377 0.01 17
> a128 1 3205784 0.196504377 0.02 18
> a129 1 3210685 0.196504377 0.03 19
> a130 1 3218542 0.196504377 0.04 20
> a131 1 3234318 0.196504377 0.05 21
> a132 1 3239972 0.196504377 0.09 22
> a133 1 3245663 0.196504377 0.05 23
> a134 1 3257997 0.196504377 0.02 24
> a135 1 3273226 0.196504377 0.03 26
> a136 1 3285404 0.196504377 0.04 27
> a137 1 3290332 0.196504377 0.05 28
> a138 1 3300679 0.196504377 0.03 29
> a139 1 3310164 0.196504377 0.09 30
>
>
> first of all, please pay attention to the P -values, all the
> rows with the p-value <0.05 will be considered as one region
> until the p-value >0.05 identified. for instance: REGION 1 is
> the rows from id a111 to id A115 .
> REGION 2 is the rows from id a118 to a123, etc.
>
> what i am going to accomplish is to pick the start and end
> location, and the peak value from the item_values for each region.
>
> option 1:
>
> loop through each row until the p-value>0.05 identified then
> start_location=the first location value
> end_location=the location value before the p>0.05
> peak_value of the item_values=the maximum one
>
> option 2
>
> create a sequence number for each row;
> subset the raw dataframe by p<0.05;
> the p-value regions will be identified by the gapped
> sequence number.
> for instance
> from sequence 1 to 5 will be considering one region.
>
> Id cat1 location item_values
> p-values sequence
> a111 1 3002737 0.196504377 0.01 1
> a112 1 3017821 0.196504377 0.05 2
> a113 1 3027730 0.196504377 0.02 3
> a114 1 3036220 0.196504377 0.04 4
> a115 1 3053984 0.196504377 0.03 5
> a118 1 3090500 0.196504377 0.02 8
> a119 1 3103304 0.196504377 0.03 9
>
>
> I need your recommendation on the different approach to
> implement this?
> Thanks,
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/data-arranged-by-p-values-tp2301
> 909p2301909.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in this message
and any annex are purely those of the writer and may not be regarded as stating
an official position of INBO, as long as the message is not confirmed by a duly
signed document.