Seq {lazy.tools}R Documentation

Smart Sequence Generation

Description

Smart Sequence Generation

Usage

Seq(from, to, decreasing = 0)

Arguments

from

the starting value of the sequence

to

the ending value of the sequence

decreasing

= 1 to generate the decreasing sequence

Details

This function is defined as

  from-1 + seq_len(max(0,to-from+1))

so that when from > to Seq( from, to ) returns numeric(0).

Basically, same as

Seq <- function(from, to) {
  if (from <= to) {
     return(from:to)
  } else {
     return(numeric(0))
  }
}

Examples

cat("Seq(3,5)\n")
for( i in Seq(3,5) ) print(i)
cat("Seq(5,3)\n")
for( i in Seq(5,3) ) print(i)
cat("seq(5,3)\n")
for( i in seq(5,3) ) print(i)
cat("\nSeq(3,5, decreasing=1)\n")
for( i in Seq(3,5, decreasing=1) ) print(i)
cat("Seq(5,3, decreasing=1)\n")
for( i in Seq(5,3, decreasing=1) ) print(i)


[Package lazy.tools version 0.1.6 ]