[R] multiple peaks in data frame

Wilkinson, Mark Mark.Wilkinson at stjude.org
Thu Nov 27 00:30:15 CET 2003


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

______________________________________________
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