[R] Converting character to numeric using the package "XLConnect"

Jim Lemon drjimlemon at gmail.com
Thu Aug 31 06:09:12 CEST 2017


Hi Nelly,
It would be helpful to see what you are actually trying to convert:

strtoi("1")
[1] 1

What is in set[10,1]?

Jim

On Thu, Aug 31, 2017 at 2:01 PM, Nelly Reduan <nell.redu at hotmail.fr> wrote:

> Thanks very much for your answer.
>
> I’m trying the function “strtoi” but it fails to convert character to
> numeric after the command "set[index] <- strtoi(set[index])".
>
>
> > strtoi(set[index]) ## This works: all values are numeric !!!
>
> [1] 1 2 3 4 2 8 9 7
>
>
>
> > set[index] <- strtoi(set[index])
>
>
>
> > print(set[10,1]) ## Problem: must be numeric !!!!
>
> [1] "1"
>
> Thanks very much for your help.
> Nell
>
> ------------------------------
> *De :* Jim Lemon <drjimlemon at gmail.com>
> *Envoyé :* mercredi 30 août 2017 15:00:32
> *À :* Nelly Reduan; r-help mailing list
> *Objet :* Re: [R] Converting character to numeric using the package
> "XLConnect"
>
> Hi Nelly,
> Are you trying to convert hexadecimal to decimal?
>
>  nrdf
>       Setting Value
> 1  Parameters     a
> 2  Parameters     b
> 3  Parameters     c
> 4  Parameters     d
> 5  Parameters     e
> 6  Parameters     2
> 7  Parameters     8
> 8  Parameters     9
> 9  Parameters     7
> 10          1     a
> 11          2     b
> 12          3     c
> 13          4     d
>
> strtoi(nrdf$Value,16)
>  [1] 10 11 12 13 14  2  8  9  7 10 11 12 13
>
> Jim
>
> On Thu, Aug 31, 2017 at 6:30 AM, Nelly Reduan <nell.redu at hotmail.fr>
> wrote:
> > The Excel file can be found from this link: https://1drv.ms/x/s!
> Apkg2VlgfYyDgQ_mcJ8F4CaXV_Nh
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list