x <- "ABCDEF"
stopifnot( strslice( x, 2 ) == c("AB", "CD", "EF") )
## applying strslice to a vector of 'strings'
y <- c("ABCD", "EFGH", "IJK") ## note unequal length
sapply( y, function(x) { strslice(x, 2) } ) ## each element sliced; warning generated for "IJK"
Run the code above in your browser using DataLab