rm(x) rm(y) #Exercice 1 #a x=c(1,8,5,1) #b y=c(0,seq(from=1, to=9, by=2)) y rm(y) y=c(0,seq(1,9,by=2)) y rm(y) y=c(0,1:5*2-1) y #c y[4] y[2:4] y[-2] y[y<=5] #d y[1:3*2] #e y[y>1] #f y[-1] #g colors() barplot(y,col=c("red","goldenrod","seagreen")) hist(y,col=rainbow(4),breaks=c(0,3,5,9),main="Titre") hist(y,col=c("violetred","yellow2"),breaks=c(0,3,5,9),main="Autre Titre") #Exercice 2 #a x y plot(x,y) # ne marche pas! #b x=c(x,3,5) x plot(x,y) #c plot(x,y) points(2,3,col='red') #d abline(lsfit(x,y)) #e cor(x,y) #pas du tout raisonnable! #Exercice 3 #a data("sunspot.year") data("sunspot.month") ?sunspot.month sunspot.month sunspot.year #b hist(sunspot.year) barplot(c(sunspot.year)) hist(sunspot.month) barplot(c(sunspot.month)) #c x=c(rep(1:11,30))[1:289] y=c(sunspot.year) cor(x,y) # JK x plot(x,y) x=c(rep(1:7,100)[1:289]) y=c(sunspot.year) cor(x,y) #11 annees a une correlation beaucoup plus elevees que d'autres periodes choisies #d sunspot.month length(sunspot.month) x=rep(seq(1:132),100)[1:3177] y=sunspot.month cor(x,y) plot(x,y) x=rep(seq(1:131),100)[1:3177] #y=sunspot.month cor(x,y) plot(x,y) x=rep(seq(1:130),100)[1:3177] #y=sunspot.month cor(x,y) plot(x,y) #Exercice 4 #a data() data(women) women xx=c(women$height) yy=c(women$weight) plot(xx,yy) abline(lsfit(xx,yy)) #correlation taille, poids cor(xx,yy) xsq=xx^2 plot(xsq,yy) abline(lsfit(xsq,yy)) #correlation taille^2, poids cor(xsq,yy) xn=xx^3 plot(xn,yy) abline(lsfit(xn,yy)) #correlation taille^3, poids cor(xn,yy) xlog=log(xx) ylog=log(yy) plot(xlog,ylog) abline(lsfit(xlog,ylog)) lsfit(xlog,ylog) xp=xx^1.6 cor(xp,yy)