在 R 编程中为指定方程创建线曲线 – curve()函数
R 语言中的curve()
函数用于为参数中指定的方程绘制曲线。
Syntax: curve(expression, to, from, col)
Parameters:
expression: To be curved
to, from: range of curve plotting
col: color of curve
示例 1:
# R program to create a curve
# Creating curve using curve() function
curve(x ^ 2 + x + 5, -4, 4, col ="green", ylab ="y")
输出:
示例 2:
# R program to create a curve
# Creating curve using function
fun <- function(x) {x ^ 3 + 4}
curve(fun, -4, 4, col ="red", ylab ="y")
输出: