On Mon, 2 May 2011, P Ehlers wrote:

Use str_sub() in the stringr package:

require(stringr)  # install first if necessary
s <- "abcdefghijklmnopqrstuvwxyz"

str_sub(s, c(1,12,17), c(3,15,-1))
#[1] "abc"        "lmno"       "qrstuvwxyz"


Thanks. That's very close to what I'm looking for, but it seems to correspond to "cut -c", not to "cut -f". Can it work with delimiters or only with character counts?

Mike


x <- "this is a string"
unlist(strsplit(x," "))[c(1,4)]

HTH Christian


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to