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 <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> 
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:      [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent:     Wednesday, November 26, 2003 4:09 PM
To:     [EMAIL PROTECTED]
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

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to