[R] Conversion from expression to numeric

2006-11-23 Thread Paul Smith
Dear All I am trying to convert from the type expression to the type numeric. The following works: x - expression(6.2) as.numeric(as.character(x)) [1] 6.2 However, the following does not work: x - expression(62/100) as.numeric(as.character(x)) [1] NA Warning message: NAs introduced by

Re: [R] Conversion from expression to numeric

2006-11-23 Thread Barry Rowlingson
Paul Smith wrote: x - expression(62/100) as.numeric(as.character(x)) [1] NA Warning message: NAs introduced by coercion Any idea about how to deal with the second case? eval-uate the expression: x - expression(62/100) eval(x) [1] 0.62 Barry

Re: [R] Conversion from expression to numeric

2006-11-23 Thread Paul Smith
On 11/23/06, Barry Rowlingson [EMAIL PROTECTED] wrote: x - expression(62/100) as.numeric(as.character(x)) [1] NA Warning message: NAs introduced by coercion Any idea about how to deal with the second case? eval-uate the expression: x - expression(62/100) eval(x) [1]

Re: [R] Conversion from expression to numeric

2006-11-23 Thread Peter Dalgaard
Paul Smith [EMAIL PROTECTED] writes: Dear All I am trying to convert from the type expression to the type numeric. The following works: x - expression(6.2) as.numeric(as.character(x)) [1] 6.2 However, the following does not work: x - expression(62/100)

Re: [R] Conversion from expression to numeric

2006-11-23 Thread Paul Smith
On 23 Nov 2006 18:20:17 +0100, Peter Dalgaard [EMAIL PROTECTED] wrote: I am trying to convert from the type expression to the type numeric. The following works: x - expression(6.2) as.numeric(as.character(x)) [1] 6.2 However, the following does not work: x -

Re: [R] Conversion from expression to numeric

2006-11-23 Thread Gabor Grothendieck
On 11/23/06, Paul Smith [EMAIL PROTECTED] wrote: On 23 Nov 2006 18:20:17 +0100, Peter Dalgaard [EMAIL PROTECTED] wrote: I am trying to convert from the type expression to the type numeric. The following works: x - expression(6.2) as.numeric(as.character(x)) [1] 6.2

Re: [R] Conversion from expression to numeric

2006-11-23 Thread Peter Dalgaard
Paul Smith [EMAIL PROTECTED] writes: Thanks, Peter. I did not know about the existence of the command 'eval', in spite of the fact of having searched the Internet for a solution for my problem. 'eval' seems not working in connection with Ryacas: library(Ryacas) x - yacas(2/3*5/7) x

Re: [R] Conversion from expression to numeric

2006-11-23 Thread Gabor Grothendieck
Also note that Ryacas provides an Eval which has a yacas method that simplifies writing this: library(Ryacas) Eval(yacas(1/2)) See ?Eval On 11/23/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: On 11/23/06, Paul Smith [EMAIL PROTECTED] wrote: On 23 Nov 2006 18:20:17 +0100, Peter Dalgaard