R type conversion [removed]) function()

前端 未结 3 1923
渐次进展
渐次进展 2021-02-15 03:15

I\'ve been trying to write a program in R that implements Newton\'s method. I\'ve been mostly successful, but there are two little snags that have been bothering me. Here\'s m

3条回答
  •  日久生厌
    2021-02-15 04:00

    Josh has answered your question

    For part 2 you could have used

    g <- expression( sin(x) )
    
    g[[1]]
    # sin(x)
    
    f <- function(x){ eval( g[[1]] ) }
    
    f(0)
    # [1] 0
    f(pi/6)
    # [1] 0.5
    

提交回复
热议问题