On Fri, Jun 8, 2012 at 10:25 AM, David Winsemius <dwinsem...@comcast.net> wrote: > > On Jun 8, 2012, at 1:11 PM, Ben quant wrote: > >> Hello, >> >> How do I change this: >>> >>> cnt_str >> >> [1] "\002" "\001" "\102" >> >> ...to this: >>> >>> cnt_str >> >> [1] "2" "1" "102" >> >> Having trouble because of this: >>> >>> nchar(cnt_str[1]) >> >> [1] 1 > > > "\001" is ASCII cntrl-A, a single character. > > ?Quotes # not the first, second or third place I looked but I knew I had > seen it before.
If you still want to obtain the actual codes, you will be able to get the number using utf8ToInt from package base or AsciiToInt from package sfsmisc. By default, the integer codes will be printed in base 10, though. A roundabout way, assuming your are on a *nix system, would be to dump() cnt_str into a file, say tmp.txt, then run in a shell (or using system() ) something like sed --in-place 's/\\//g' tmp.txt to remove the slashes, then use cnt_str_new = read.table("tmp.txt") in R to get the codes back in. I'll let you iron out the details. Peter ______________________________________________ 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.