Professional Documents
Culture Documents
apply
> X<-matrix(c(1:9), nrow=3, byrow=T)
> apply(x,1,mean)
Error in apply(x, 1, mean) : dim(X) doit avoir un longueur positive
> apply(x,2,mean)
Error in apply(x, 2, mean) : dim(X) doit avoir un longueur positive
> install.packages("ggplot2")
WARNING: Rtools is required to build R packages but is not currently installed.
Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/ASUS/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
essai de l'URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/ggplot2_3.3.3.zip'
Content type 'application/zip' length 4071652 bytes (3.9 MB)
downloaded 3.9 MB
x, y
> qqnorm(depth)
> hist(depth)
> hist(depth, xlab = "diameter des diamonds", col = "yellow", border = "blue")
> hist(depth, xlab = "diameter des diamonds", col = "green", border = "red", xlim =
c(55,65), ylim =
+ c(0,2500), breaks = 2500)
> depthsmall <- sample(depth, 5000)
> shapiro.test(depthsmall)
data: depthsmall
W = 0.93474, p-value < 2.2e-16
data: y
W = 0.34871, p-value < 2.2e-16
> ?dnorm
> x <- seq(-10,10,by = .2)
> y <- pnorm(x, mean = 2.5, sd = 2)
> plot(x,y)
> shapiro.test(y)
data: y
W = 0.75029, p-value = 8.188e-12
data: y
W = NaN, p-value = NA
data: y
W = 0.9781, p-value = 0.4747
> boxplot(y, data = rnorm, xlab = "Loi Normale", ylab = " Nombre aleatoire ", main
= "boite a
+ maustache")
> boxplot(y, data = rnorm, xlab = "Loi Normale", ylab = "Nombre aleatoire", main =
"boite a
+ maustache", notch = TRUE, varwidth = TRUE, col = c("green"), names = c("High"))
> mtcars[,c('mpg','cyl')]
mpg cyl
Mazda RX4 21.0 6
Mazda RX4 Wag 21.0 6
Datsun 710 22.8 4
Hornet 4 Drive 21.4 6
Hornet Sportabout 18.7 8
Valiant 18.1 6
Duster 360 14.3 8
Merc 240D 24.4 4
Merc 230 22.8 4
Merc 280 19.2 6
Merc 280C 17.8 6
Merc 450SE 16.4 8
Merc 450SL 17.3 8
Merc 450SLC 15.2 8
Cadillac Fleetwood 10.4 8
Lincoln Continental 10.4 8
Chrysler Imperial 14.7 8
Fiat 128 32.4 4
Honda Civic 30.4 4
Toyota Corolla 33.9 4
Toyota Corona 21.5 4
Dodge Challenger 15.5 8
AMC Javelin 15.2 8
Camaro Z28 13.3 8
Pontiac Firebird 19.2 8
Fiat X1-9 27.3 4
Porsche 914-2 26.0 4
Lotus Europa 30.4 4
Ford Pantera L 15.8 8
Ferrari Dino 19.7 6
Maserati Bora 15.0 8
Volvo 142E 21.4 4
> > boxplot(mpg ~ cyl, data = mtcars, xlab = "Number of Cylinders", ylab = "Miles
Per Gallon", main =
+ "Mileage Data", notch = TRUE, varwidth = TRUE, col =
c("green","yellow","purple"), names =
+ c("High","Medium","Low"))
Warning message:
In bxp(list(stats = c(21.4, 22.8, 26, 30.4, 33.9, 17.8, 18.65, 19.7, :
Quelques indentations ("notches") dépassent des jointures ("hinges") ('box') :
utilisez peut-être notch=FALSE
> summary(mtcars)
mpg cyl
Min. :10.40 Min. :4.000
1st Qu.:15.43 1st Qu.:4.000
Median :19.20 Median :6.000
Mean :20.09 Mean :6.188
3rd Qu.:22.80 3rd Qu.:8.000
Max. :33.90 Max. :8.000
disp hp
Min. : 71.1 Min. : 52.0
1st Qu.:120.8 1st Qu.: 96.5
Median :196.3 Median :123.0
Mean :230.7 Mean :146.7
3rd Qu.:326.0 3rd Qu.:180.0
Max. :472.0 Max. :335.0
drat wt
Min. :2.760 Min. :1.513
1st Qu.:3.080 1st Qu.:2.581
Median :3.695 Median :3.325
Mean :3.597 Mean :3.217
3rd Qu.:3.920 3rd Qu.:3.610
Max. :4.930 Max. :5.424
qsec vs
Min. :14.50 Min. :0.0000
1st Qu.:16.89 1st Qu.:0.0000
Median :17.71 Median :0.0000
Mean :17.85 Mean :0.4375
3rd Qu.:18.90 3rd Qu.:1.0000
Max. :22.90 Max. :1.0000
am gear
Min. :0.0000 Min. :3.000
1st Qu.:0.0000 1st Qu.:3.000
Median :0.0000 Median :4.000
Mean :0.4062 Mean :3.688
3rd Qu.:1.0000 3rd Qu.:4.000
Max. :1.0000 Max. :5.000
carb
Min. :1.000
1st Qu.:2.000
Median :2.000
Mean :2.812
3rd Qu.:4.000
Max. :8.000
> plot(x = mtcars$mpg, y = mtcars$cyl, xlab = "Weight", ylab = "Milage", xlim =
c(10,40), ylim = c(0,10),
+ main = "Weight vs Milage" )
> pairs(~wt+mpg+disp+cyl,data = mtcars, main = "Scatterplot Matrix")
> x <- c(14.8, 81.5, 2.7, 0.4, 1)
> labels <- c("iOS", "Android", "Windows Phone", "BlackBerry", "Autres")
> pie(x,labels)
> pie(x,labels,col = rainbow(length(x)))
> piepercent<- round(100*x/sum(x), 1)
> pie(x, labels = piepercent, main = "Mobile pie chart", col = rainbow(length(x)))
> legend("topright", labels, cex = 0.8, fill = rainbow(length(x)))
> barplot(x)
> barplot(x, names.arg = labels, xlab = "OS", ylab = "nombre utilisateur en
millions", col = "blue", main
+ = "Utilisation mondiale des mobile", border = "red")
> couleurs <- c("green","orange","brown")
> mois <- c("Mars","Avril","Mai","Juin","Juillet")
> regions <- c("Est","Ouest","Nord")
> Values <- matrix(c(2,9,3,11,9,4,8,7,3,12,5,2,8,10,11),nrow = 3,ncol = 5,byrow =
TRUE)
> barplot(Values, main = "revenue total", names.arg = mois, xlab = "mois", ylab =
"revenue", col =
+ couleurs)
> legend("topleft", regions, cex = 1.3, fill = couleurs)