R/head-methods.R

setGeneric( "head", function( x, ... ) standardGeneric( "head" ) )

setMethod(
          "head",
          signature( "Intervals_virtual" ),
          function( x, n = 6 ) {
            if ( nrow(x) > 0 ) x[ 1:min( n, nrow(x) ), ] else x
          }
          )

setGeneric( "tail", function( x, ... ) standardGeneric( "tail" ) )

setMethod(
          "tail",
          signature( "Intervals_virtual" ),
          function( x, n = 6 ) {
            if ( nrow(x) > 0 ) x[ max( 1, nrow(x) - n + 1 ):nrow(x), ] else x
          }
          )

Try the intervals package in your browser

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

intervals documentation built on July 10, 2023, 2:02 a.m.