[R] multiple peaks in data frame

Gabor Grothendieck ggrothendieck at myway.com
Thu Nov 27 01:22:01 CET 2003


Here is a minor simplification of the last statement:

df <- data.frame(V1=c(23, 4, 56, 7, 99, 33))
interval <- 2
if (nrow(df) %% interval == 0) 
     apply(matrix(df$V1,interval),2,max)

---
Date: Wed, 26 Nov 2003 17:30:15 -0600 
From: Wilkinson, Mark <Mark.Wilkinson at stjude.org>
To: <solares at unsl.edu.ar>, <R-help at stat.math.ethz.ch> 
Subject: RE: [R] multiple peaks in data frame 

 
 
I don't quite understand your English, but I'll take a stab at answering your question. If by "date" you mean "data" and by "peaks" "maxima," then

df <- data.frame(V1=c(23, 4, 56, 7, 99, 33))
interval <- 2
if (nrow(df) %% interval == 0) 
tapply(df$V1, rep(1:(nrow(df) / interval), each=interval), max)

might be what you need.


Mark Wilkinson
Informatics Analyst
St. Jude Children's Research Hospital
Department of Pharmaceutical Sciences

The opinions expressed here are my own and do not necessarily represent those of St. Jude Children's Research Hospital.


-----Original Message-----
From:      solares at unsl.edu.ar [mailto:solares at unsl.edu.ar] 
Sent:     Wednesday, November 26, 2003 4:09 PM
To:     R-help at stat.math.ethz.ch
Subject:     [R] multiple peaks in data frame

Hello, it wanted to know how I can extract of a dates frame the values 
peaks according to an interval that I
establish. For example if dates are: 
1 23
2 4
3 56
4 7
5 99
6 33
extract the date i wanted to divide into intervals of 2 an
d to take alone the numbers 23, 56 and 99 of those 3 intervals. Thanks 
Ruben




More information about the R-help mailing list