Hello all, now I'm trying to switch from Excel to R to deal with the data,
and as a newbie i got the problem as follows.

suppose I have a data named "test"
test<- data.frame(year=c(1996:2011),
Y=c(74163.6,81658.5,86531.6,91125.0,98749.0,109028.0,120475.6,136613.4,160956.6,187423.5,222712.5,266599.2,315974.6,348775.1,402816.5,465731.3))
in which Y means the GDP of a country

If i want to get Delta Y = Y(t)-Y(t-1) , i could use diff() in R
diff(test$Y)

but what if i want to get gY=(Y(t)-Y(t-1))/Y(t-1)?
seems diff(test$Y)/(test$Y)[-1] doesnt work ...

thanks in advance

	[[alternative HTML version deleted]]

