[R] index

Antonio Gasparrini Antonio.Gasparrini at lshtm.ac.uk
Wed Jan 2 16:35:16 CET 2008


Dear all,

I would like to know if it’s possible to create an index for a variable/vector that specifies the value in the n position before the actual value.

For example, if X <- c(letters[1:10]), x[10] is “j”. I would like to create an index exp3 (the third position before) such as if z <- x[exp3], then z[10] = “g”.

In Stata that index is x[-3], but not in R.

I have to input it in a very complex function to be minimised with the mle command, so I can’t solve this problem with a loop.

Can you help me?




More information about the R-help mailing list