On Sep 5, 2010, at 9:22 AM, rajesh j wrote:

> for e.g., I get the following as a string vector
> "int" "4" "5" "6"
> after reading the first element, I have to convert this to a integer  
> vector

But what is the right answer?  And what number of items are possble  
per line?  And what are the other possible type identifiers? We need  
an example that has enough complexity to allow testing.

-- 
David.


>
> On Sun, Sep 5, 2010 at 6:44 PM, David Winsemius <dwinsem...@comcast.net 
> > wrote:
>
> On Sep 5, 2010, at 8:48 AM, rajesh j wrote:
>
> Hi,
>
> Is it possible to convert a string vector to integer or numeric  
> vector? In
> my situation I receive data in a string vector and have to convert  
> it based
> on a given type.
>
> Can you give an example? I don't understand either what sort of  
> conversion you desire or what you mean by "convert it based on a  
> given type."
>
> There are a couple of function you may want to consider but I am  
> having difficulty convincing myself they answer the problem posed:
>
> ?charToRaw
> ?stroi
>
> > strtoi(charToRaw("123 this is a string"), base=16)   # convert to  
> decimal ASCII
>  [1]  49  50  51  32 116 104 105 115  32 105 115  32  97  32 115 116  
> 114 105 110 103
>
> -- 
>
> David Winsemius, MD
> West Hartford, CT
>
>
>
>
> -- 
> Rajesh.J
>
>

David Winsemius, MD
West Hartford, CT


        [[alternative HTML version deleted]]

______________________________________________
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