[R] converting a character string to a subscripted numeric variable

Charles Annis, P.E. Charles.Annis at StatisticalEngineering.com
Thu Nov 10 22:46:16 CET 2005


Dear R-helpers:

It seems that I have a mental block.  (Some say that it sits atop my
shoulders.)

For reasons too tedious to retell I have an R object:

> input.line[7]
[1] "-13.24, -11.24, -9.24, -7.24, -5.24, -3.24, -1.24, 0.76, 2.76, 4.76,
6.76, 8.76, 10.76, 12.76, 14.76, 16.76, 18.76, 20.76, 22.76, 24.76, 26.76,
28.76, 30.76, 32.76, 34.76, 36.76, 38.76, 40.76, 42.76, 44.76, "
>

I would like to convert this into a subscripted variable, Beta, something
that should be straightforward if I had *almost* what I have.

I'd like to say

Beta <- c(-13.24, -11.24, -9.24, -7.24, -5.24, -3.24, -1.24, 0.76, 2.76,
4.76, 6.76, 8.76, 10.76, 12.76, 14.76, 16.76, 18.76, 20.76, 22.76, 24.76,
26.76, 28.76, 30.76, 32.76, 34.76, 36.76, 38.76, 40.76, 42.76, 44.76)

but I can't because:

input.line[7] is a character string, and

it ends in a comma.


This cannot be as difficult as I have found it to be.  Can anyone help?

Copious Thanks.


Charles Annis, P.E.

Charles.Annis at StatisticalEngineering.com
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 




More information about the R-help mailing list