RosettaCodeData/Task/Substring/R/substring.r
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

9 lines
314 B
R

s <- "abcdefgh"
n <- 2; m <- 2; char <- 'd'; chars <- 'cd'
substring(s, n, n + m)
substring(s, n)
substring(s, 1, nchar(s)-1)
indx <- which(strsplit(s, '')[[1]]%in%strsplit(char, '')[[1]])
substring(s, indx, indx + m)
indx <- which(strsplit(s, '')[[1]]%in%strsplit(chars, '')[[1]])[1]
substring(s, indx, indx + m)