Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ggplot2对R中的函数进行曲线拟合_R - Fatal编程技术网

使用ggplot2对R中的函数进行曲线拟合

使用ggplot2对R中的函数进行曲线拟合,r,R,我举了以下例子: seed(123) x<-runif(100) y<-runif(100) f <- function(x) { return(4 * x * (1 - x)) } 种子(123) x使用stat\u函数() df df <- data.frame(x= runif(100), y = runif(100)) f <- function(x) { return(4 * x * (1 - x)) } ggplot(aes(x,y), data

我举了以下例子:

seed(123)
x<-runif(100)
y<-runif(100)

f <- function(x) { return(4 * x * (1 - x)) }
种子(123)
x使用
stat\u函数()

df
df <- data.frame(x= runif(100), y = runif(100))
f <- function(x) { return(4 * x * (1 - x)) }

ggplot(aes(x,y), data = df) + geom_point() +
stat_function(fun=f)