Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

clipVector

Clip a Vector at One or Both Ends


Description

Clip a vector at one or both ends using the specified clip pattern to match.

Usage

clipVector(vec, clip, end=0)

Arguments

vec

vector object to clip

clip

value or string specifying repeated values to clip from ends

end

end to clip clip from: 0=both, 1=front, 2=back

Details

If the vector is named, the names are retained. Otherwise, element positions are assigned as the vector's names.

Value

Clipped vector with names.

Author(s)

Rowan Haigh, Pacific Biological Station, Fisheries and Oceans Canada, Nanaimo BC

See Also

Examples

local(envir=.PBSmodEnv,expr={
  x=c(0,0,0,0,1,1,1,1,0,0)
  print(clipVector(x,0))

  x=c(TRUE,TRUE,FALSE,TRUE)
  print(clipVector(x,TRUE))

  x=c("red","tide","red","red")
  print(clipVector(x,"red",2))
})

PBSmodelling

GUI Tools Made Easy: Interact with Models and Explore Data

v2.68.8
GPL (>= 2)
Authors
Jon T. Schnute [aut], Alex Couture-Beil [aut], Rowan Haigh [aut, cre], Nicholas Boers [ctb], Anisa Egeli [ctb], A. R. Kronlund [ctb], Steve Martell [ctb], Norm Olsen [ctb]
Initial release
2019-03-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.