Read exponential numbers from console

R programming language resources Forums Data manipulation Read exponential numbers from console

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #461
    liquider
    Member

    Hi guys!

    I’m trying to read some input numbers from console but I’m facing the following problem. When input value is something like 10^4 I cannot convert this input to a numeric value.

    My code looks like:

    number <- readline("Enter number: ") number <- as.numeric(number) The result is NA Does someone any idea what I could do to convert the input string in a numeric value? Thanks a lot!! Peter

    #463
    bryan
    Participant

    One way to do this is by using parse and eval:

    number <- readline("Enter number: ") number <- eval(parse(text = number))

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Scroll to top
Privacy Policy