R/first.R

Defines functions last first

Documented in first last

first <- function(x, n=1, ...) head(x, n=n, ...)
last  <- function(x, n=1, ...) tail(x, n=n, ...)

"first<-" <- function(x, n=1, ..., value)
{
  x[1:n] <- value[1:n]
  x
}

"last<-" <- function(x, n=1, ..., value)
{
  index <- seq(length(x)-n+1, length(x))
  x[index] <- value[1:n]
  x
}

Try the gdata package in your browser

Any scripts or data that you put into this service are public.

gdata documentation built on Oct. 17, 2023, 1:11 a.m.