An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120220/afdac6b1/attachment.pl>
counting characters starting point
2 messages · Juliet Ndukum, Rui Barradas
Hello,
Try
seq1 <- 'PQRTUWXY'
seq2 <- 'AQSDSSDHRS'
seq3 <- 'EEZYJKFFBHO'
ref1 <- 'U'
ref2 <- 'S'
ref3 <- 'Y'
fun <- function(seq, chr){
f <- function(x, seq, chr){
pos <- regexpr(x, seq)
if(pos < 0)
99
else
as.integer(pos - regexpr(chr, seq))
}
sapply(LETTERS, f, seq, chr)
}
rbind(
fun(seq1, ref1),
fun(seq2, ref2),
fun(seq3, ref3)
)
Hope this helps,
Rui Barradas
--
View this message in context: http://r.789695.n4.nabble.com/counting-characters-starting-point-tp4405233p4405475.html
Sent from the R help mailing list archive at Nabble.com.