Clip a Vector at One or Both Ends
Clip a vector at one or both ends using the specified clip pattern to match.
clipVector(vec, clip, end=0)
vec
: vector object to clipclip
: value or string specifying repeated values to clip from endsend
: end to clip clip
from: 0=both, 1=front, 2=backIf the vector is named, the names are retained. Otherwise, element positions are assigned as the vector's names.
Clipped vector with names.
Rowan Haigh, Pacific Biological Station, Fisheries and Oceans Canada, Nanaimo BC
createVector
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)) })