This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.
sample(cars)
## speed dist
## 1 4 2
## 2 4 10
## 3 7 4
## 4 7 22
## 5 8 16
## 6 9 10
## 7 10 18
## 8 10 26
## 9 10 34
## 10 11 17
## 11 11 28
## 12 12 14
## 13 12 20
## 14 12 24
## 15 12 28
## 16 13 26
## 17 13 34
## 18 13 34
## 19 13 46
## 20 14 26
## 21 14 36
## 22 14 60
## 23 14 80
## 24 15 20
## 25 15 26
## 26 15 54
## 27 16 32
## 28 16 40
## 29 17 32
## 30 17 40
## 31 17 50
## 32 18 42
## 33 18 56
## 34 18 76
## 35 18 84
## 36 19 36
## 37 19 46
## 38 19 68
## 39 20 32
## 40 20 48
## 41 20 52
## 42 20 56
## 43 20 64
## 44 22 66
## 45 23 54
## 46 24 70
## 47 24 92
## 48 24 93
## 49 24 120
## 50 25 85
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
cor(cars)
## speed dist
## speed 1.0000000 0.8068949
## dist 0.8068949 1.0000000
boxplot(cars)
lm(cars)
##
## Call:
## lm(formula = cars)
##
## Coefficients:
## (Intercept) dist
## 8.2839 0.1656
cars1<-lm(dist ~ speed, data = cars)
par(mfrow = c(2, 2))
plot(cars1)
Droite <- read.csv("Droite.csv", sep=";")
plot(cars)
plot(pressure)
donnees<-read.csv2("Droite.csv")
print(t(donnees))# x=variable explicative, y=variable expliquée, t transpostion du tableau
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
## Taille "1.56" "1.63" "1.67" "1.67" "1.69" "1.64" "1.63" "1.56" "1.67" "1.72"
## Poids "47" "44" "52" "61" "54" "47" "44" "47" "52" "57"
## [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20]
## Taille "1.67" "1.56" "1.69" "1.7" "1.63" "1.67" "1.55" "1.63" "1.64" "1.56"
## Poids "52" "47" "54" "52" "53" "52" "46" "44" "47" "47"
## [,21] [,22] [,23] [,24] [,25] [,26] [,27] [,28] [,29] [,30]
## Taille "1.75" "1.72" "1.67" "1.68" "1.72" "1.62" "1.69" "1.6" "1.56" "1.65"
## Poids "54" "56" "52" "55" "62" "48" "57" "45" "45" "58"
## [,31] [,32] [,33] [,34] [,35] [,36] [,37] [,38] [,39] [,40]
## Taille "1.79" "1.69" "1.73" "1.64" "1.63" "1.63" "1.7" "1.62" "1.67" "1.69"
## Poids "64" "51" "54" "47" "52" "53" "52" "50" "47" "54"
## [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49] [,50]
## Taille "1.63" "1.6" "1.73" "1.61" "1.56" "1.48" "1.6" "1.69" "1.64" "1.56"
## Poids "52" "44" "57" "43" "47" "38" "44" "54" "47" "45"
## [,51] [,52] [,53] [,54] [,55] [,56] [,57] [,58] [,59] [,60]
## Taille "1.63" "1.55" "1.67" "1.73" "1.67" "1.69" "1.63" "1.67" "1.56" "1.68"
## Poids "44" "47" "47" "57" "61" "51" "52" "52" "47" "50"
## [,61] [,62] [,63] [,64] [,65] [,66] [,67] [,68] [,69] [,70]
## Taille "1.63" "1.6" "1.75" "1.73" "1.75" "1.61" "1.67" "1.62" "1.69" "1.64"
## Poids "44" "48" "54" "66" "53" "50" "47" "56" "57" "52"
## [,71] [,72] [,73] [,74] [,75] [,76] [,77] [,78] [,79] [,80]
## Taille "1.62" "1.6" "1.72" "1.64" "1.7" "1.7" "1.65" "1.67" "1.65" "1.62"
## Poids "52" "50" "56" "65" "55" "59" "55" "50" "55" "47"
## [,81] [,82] [,83] [,84] [,85] [,86] [,87] [,88] [,89] [,90] [,91]
## Taille "1.57" "1.6" "1.6" "1.6" "1.71" "1.67" "1.6" "1.79" "1.64" "1.7" "1.61"
## Poids "48" "48" "48" "44" "53" "52" "49" "64" "56" "51" "51"
## [,92] [,93] [,94] [,95] [,96] [,97] [,98] [,99] [,100] [,101]
## Taille "1.68" "1.68" "1.73" "1.68" "1.74" "1.6" "1.48" "1.65" "1.67" "1.67"
## Poids "50" "56" "54" "55" "70" "43" "38" "54" "55" "55"
## [,102] [,103] [,104] [,105] [,106] [,107] [,108] [,109] [,110] [,111]
## Taille "1.65" "1.7" "1.67" "1.62" "1.7" "1.6" "1.51" "1.67" "1.64" "1.68"
## Poids "48" "52" "54" "48" "55" "45" "54" "48" "50" "63"
## [,112] [,113] [,114] [,115] [,116] [,117] [,118] [,119] [,120] [,121]
## Taille "1.55" "1.65" "1.63" "1.66" "1.68" "1.65" "1.64" "1.7" "1.71" "1.7"
## Poids "53" "48" "59" "53" "51" "60" "59" "60" "57" "53"
## [,122] [,123] [,124] [,125] [,126] [,127] [,128] [,129] [,130] [,131]
## Taille "1.62" "1.5" "1.6" "1.65" "1.69" "1.6" "1.65" "1.67" "1.65" "1.55"
## Poids "60" "40" "50" "53" "58" "42" "44" "60" "63" "43"
## [,132] [,133] [,134] [,135] [,136] [,137] [,138] [,139] [,140] [,141]
## Taille "1.65" "1.56" "1.63" "1.65" "1.72" "1.58" "1.62" "1.61" "1.55" "1.61"
## Poids "61" "45" "52" "56" "56" "47" "48" "56" "49" "43"
## [,142] [,143] [,144]
## Taille "1.72" "1.64" "1.76"
## Poids "56" "63" "58"
attach((donnees))
eq=paste0("Nuage de points : observations")
plot(Taille,Poids,type="p",pch=4,main=eq,col="blue")
plot(donnees)
donnees$Taille
## [1] "1.56" "1.63" "1.67" "1.67" "1.69" "1.64" "1.63" "1.56" "1.67" "1.72"
## [11] "1.67" "1.56" "1.69" "1.7" "1.63" "1.67" "1.55" "1.63" "1.64" "1.56"
## [21] "1.75" "1.72" "1.67" "1.68" "1.72" "1.62" "1.69" "1.6" "1.56" "1.65"
## [31] "1.79" "1.69" "1.73" "1.64" "1.63" "1.63" "1.7" "1.62" "1.67" "1.69"
## [41] "1.63" "1.6" "1.73" "1.61" "1.56" "1.48" "1.6" "1.69" "1.64" "1.56"
## [51] "1.63" "1.55" "1.67" "1.73" "1.67" "1.69" "1.63" "1.67" "1.56" "1.68"
## [61] "1.63" "1.6" "1.75" "1.73" "1.75" "1.61" "1.67" "1.62" "1.69" "1.64"
## [71] "1.62" "1.6" "1.72" "1.64" "1.7" "1.7" "1.65" "1.67" "1.65" "1.62"
## [81] "1.57" "1.6" "1.6" "1.6" "1.71" "1.67" "1.6" "1.79" "1.64" "1.7"
## [91] "1.61" "1.68" "1.68" "1.73" "1.68" "1.74" "1.6" "1.48" "1.65" "1.67"
## [101] "1.67" "1.65" "1.7" "1.67" "1.62" "1.7" "1.6" "1.51" "1.67" "1.64"
## [111] "1.68" "1.55" "1.65" "1.63" "1.66" "1.68" "1.65" "1.64" "1.7" "1.71"
## [121] "1.7" "1.62" "1.5" "1.6" "1.65" "1.69" "1.6" "1.65" "1.67" "1.65"
## [131] "1.55" "1.65" "1.56" "1.63" "1.65" "1.72" "1.58" "1.62" "1.61" "1.55"
## [141] "1.61" "1.72" "1.64" "1.76"
c1<-rep(1,144)
X<-matrix(c(c1,as.numeric(donnees$Taille)),ncol=2)
Y<-matrix(as.numeric(donnees$Poids),ncol=1)
M<-t(X)%*%X
b<-t(X)%*%Y
a=solve(M,b)
plot(Taille,Poids,type="p",pch=4,main=eq,col="blue")
abline(a,col="red",main=eq)
eq=paste0("Droite de regression : y =", round(a[2],3),"*x +",round(a[1],3))
title(sub=eq)
length(Poids)
## [1] 144