[R] strings

Kurt Hornik Kurt.Hornik at ci.tuwien.ac.at
Wed Oct 4 08:06:40 CEST 2000

>>>>> Richard Rowe writes:

> I am attempting to analyse some behaviour sequence data.  The input is
> an alphabetic string "ASDFGH ... ".  I wish to start at one end of the
> string, peel off each character, and convert to an integer to develop
> transition matrices etc. My blundering through the ref manual hasn't
> produced any light.

> Can this be done easily in R or should I pre-process?

> I recollect an item similar to this on R-help around 6 mo ago but I
> can't find it in the archive. If there is such an article can someone
> please send me the date and I will track it down,


Not sure what precisely you need ... if it is about converting a string
to a vector of characters, you could use

	R> x <- "ASDFGH"
	R> x
	[1] "ASDFGH"
	R> unlist(strsplit(x, NULL))
	[1] "A" "S" "D" "F" "G" "H"

and proceed from there.

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list