[R] Extract from data.frame

Nico Gutierrez nico.gutierrezo at gmail.com
Mon Sep 21 16:52:46 CEST 2015


Hi All,

I need to do the following operation from data.frame:

df <- data.frame(Year = c("2001", "2002", "2003", "2004", "2005", "2006",
"2007"), Amount = c(150, 120, 175, 160, 120, 105, 135))
df[which.max(df$Amount),]  #to extract row with max Amount.

Now I need to do 3 years average around the max Amount value (ie:
mean(120,175,160))

Thanks!
N

	[[alternative HTML version deleted]]



More information about the R-help mailing list