data(iris) head(iris) plot(iris$Petal.Length,iris$Petal.width) #x<-iris$Petal.Length #y<-iris$Petal.width #g=glm(x~y,family=binomial) #curve(predict(g,data.frame(iris$Petal.Length=x),type="resp"),add=TRUE) x<-c(rep(1:20)) y<-x*2 f<-lm(x ~ y) f plot(x,y) e<-lm(y ~x ) e plot(x,y) #library(tidyverse) #problem 1 library(ggplot2) x=1:20 y=21:40 data.frame(x,y) print(data.frame(x,y)) print(lm(y~x+ I(x^2))) plot(x,y) ggplot(data.frame(x,y),aes(y,x))+geom_point()+ stat_smooth(method=lm,formula=y~ poly(x,5,raw=TRUE)) #problem 2 library(ggplot2) data(iris) head(iris) x=iris$Sepal.Length y=iris$Petal.Length data.frame(x,y) print(data.frame(x,y)) print(lm(y~x+ I(x^2))) plot(x,y) ggplot(data.frame(x,y),aes(y,x))+geom_point()+ stat_smooth(method=lm,formula=y~ poly(x,5,raw=TRUE)) #problem 3 library(ggplot2) x=iris$Sepal.Width y=iris$Petal.Width data.frame(x,y) print(data.frame(x,y)) print(lm(y~x+ I(x^2))) plot(x,y) ggplot(data.frame(x,y),aes(y,x))+geom_point()+ stat_smooth(method=lm,formula=y~ poly(x,5,raw=TRUE))
To embed this program on your website, copy the following code and paste it into your website's HTML: