powered by
Locate the index of the first/last unique value in i) a vector or of a variable in a data frame.
lastobs(x, ...)firstobs(x, ...)# S3 method for default lastobs(x, ...)# S3 method for default firstobs(x, ...)# S3 method for formula lastobs(formula, data = parent.frame(), ...)# S3 method for formula firstobs(formula, data = parent.frame(), ...)
firstobs(x, ...)
# S3 method for default lastobs(x, ...)
# S3 method for default firstobs(x, ...)
# S3 method for formula lastobs(formula, data = parent.frame(), ...)
# S3 method for formula firstobs(formula, data = parent.frame(), ...)
A vector.
A vector
Currently not used
A formula (only the first term is used, see 'details').
A data frame
Søren Højsgaard, sorenh@math.aau.dk
If writing ~a + b + c as formula, then only a is considered.
x <- c(rep(1, 5), rep(2, 3), rep(3, 7), rep(1, 4)) firstobs(x) lastobs(x) data(dietox) firstobs(~Pig, data=dietox) lastobs(~Pig, data=dietox)
Run the code above in your browser using DataLab