R/expandToLength.R

Defines functions expandToLength

###-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# expand a sequence 'x' to be of length 'l' by adding 'what' at the start or
# end
###-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

expandToLength <- function(x, l=ceiling(length(x)/6)*6,
    what=0, where="end")
{
    if( length(x) == l )
	return(x)
    else
    {
	add <- rep(what, l - length(x))
	rval <- switch( where,
	    end= c(x, add),
	    start= c( add, x) )
	return(rval)
    }
}

Try the rgraph6 package in your browser

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

rgraph6 documentation built on May 2, 2019, 4:50 p.m.