[R] strings
Kurt Hornik
Kurt.Hornik at ci.tuwien.ac.at
Wed Oct 4 09:02:25 CEST 2000
>>>>> Martin Maechler writes:
>>>>> "KH" == Kurt Hornik <Kurt.Hornik at ci.tuwien.ac.at> writes:
>>>>> 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,
KH> Richard,
KH> Not sure what precisely you need ... if it is about converting a string
KH> to a vector of characters, you could use
R> x <- "ASDFGH"
R> x
KH> [1] "ASDFGH"
R> unlist(strsplit(x, NULL))
KH> [1] "A" "S" "D" "F" "G" "H"
KH> and proceed from there.
> which reminds me that I've had a desire for something like
> the old S function [from the blue book, and library(examples) I think]
> ichar(ch)
> which would return a vector of integers, each the (decimal) equivalent of
> the (ISO-latin1) representation of the corresponding characters in ch.
> This should be easy enough (and be done in C). Any volunteers?
That should not be hard to copy from toupper(). For a character vector
it would give a list of integer vectors?
However, I don't think we want ISO-latin-1 hard-wired ...
-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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