File: first.R

package info (click to toggle)
gdata 3.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 964 kB
  • sloc: sh: 27; makefile: 15
file content (15 lines) | stat: -rw-r--r-- 288 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
}