manzler.h
manzler.h

Reputation: 9

Error w/ R curve() function: 'expr' did not evaluate to an object of length 'n'

I am trying to write a program in R that is basically a graphing calculator. It should take a text input and then plot it.

output$plot1 <- renderPlot({
    tempTxt2 <- parse(text=input$userTxtVar)
    f1 <- function(x){
      return(tempTxt2)
    }
    curve(expr = f1, from =-3, to =3)
  })

I thought parsing the text to an expr might help. It initially gives the same error, but also causes an "unexpected symbol" error. E.g. when I type in "3x":

<text>:1:2: unexpected symbol
1: 3x
     ^

Upvotes: 1

Views: 70

Answers (0)

Related Questions