TP1

#Q1&23 X=c(1:5);X #Q5 Y=c(1,4,9,16,25);Y length(X)==length(Y) # it is true #Q7 make a graph

X=c(1:5);X
## [1] 1 2 3 4 5
Y=c(1,4,9,16,25);Y
## [1]  1  4  9 16 25
plot(X,Y,pch=2, type="b",col="red" )

plot(X,Y,pch=3, type="l",col="blue", main="Y en fonction de Y", xlab="x",ylab="Y" )

plot(X,Y,pch=2, type=“b”,col=“red” ) plot(X,Y,pch=3, type=“l”,col=“blue”, main=“Y en fonction de Y”, xlab=“x”,ylab=“Y” ) ?plot

#Q8 add an other curve curve(x^2,add=TRUE) #Q9 X=0:7;X #Q10 X=X*5;X;X=X/5;X;X=X+5;X #11 Y=sum(X);Y #somme classique Y=cumsum(X); Y # creer une vecteur

#Q12 sqrt(X); XXX

#———————————————————————————— #EXERICE 2

#4. Bind them as columns, and assign the result to XYZ.

#Q1
X=c(0,1,4,9,16);X
## [1]  0  1  4  9 16
#Q2
subv=X[3:5]; subv
## [1]  4  9 16
subv=X[X>2]; subv
## [1]  4  9 16
subv=X[X>2&X<10]; subv
## [1] 4 9
#Q3 REP REP REP
Y=(rep(1,5)); Y
## [1] 1 1 1 1 1
Z=seq(3,11,2); Z
## [1]  3  5  7  9 11
#Q3
V=c(X,Y,Z);V 
##  [1]  0  1  4  9 16  1  1  1  1  1  3  5  7  9 11
XYZ=cbind(X,Y,Z) ; XYZ
##       X Y  Z
## [1,]  0 1  3
## [2,]  1 1  5
## [3,]  4 1  7
## [4,]  9 1  9
## [5,] 16 1 11

XYZ=cbind(X,Y,Z) ; XYZ

5. Compute row sums and column sums of XYZ.

rowsums=rowSums(XYZ[1:5,]); rowsums
## [1]  4  7 12 19 28
XYZ[,1:3]
##       X Y  Z
## [1,]  0 1  3
## [2,]  1 1  5
## [3,]  4 1  7
## [4,]  9 1  9
## [5,] 16 1 11
columnZZ=colSums(XYZ[,c(1:3)]); columnZZ
##  X  Y  Z 
## 30  5 35
columnZZ=colSums(XYZ[,1:3]); columnZZ
##  X  Y  Z 
## 30  5 35

#6. Extract from XYZ: # (a) row number 4, #(b) column number 3, #(c) rows with indices 3, 5, columns with indices 2, 3, #(d) rows such that X is larger than 2. #(e) columns named “Y” and “Z”.

#a & b
XYZ[4,]
## X Y Z 
## 9 1 9
XYZ[,3]
## [1]  3  5  7  9 11
#c
XYZ[c(3:5),c(2,3)]
##      Y  Z
## [1,] 1  7
## [2,] 1  9
## [3,] 1 11
#d
XYZ[X>2,]
##       X Y  Z
## [1,]  4 1  7
## [2,]  9 1  9
## [3,] 16 1 11
#e
XYZ[,c("Y","Z")]
##      Y  Z
## [1,] 1  3
## [2,] 1  5
## [3,] 1  7
## [4,] 1  9
## [5,] 1 11

upload the document

becarfull form the separator “, or ;

#read.table(file.choose( ) ,sep=“, dec=”,“, header=”TRUE”, )

#file.chosoe() becarfule the window might be open and the file muste be closed.

#3. Exercice Study of Body Mass Index #A sample of children’s files was seized. They are children seen #during a visit to the first section of kindergarten in 1996-1997, in #schools in Bordeaux. The sample presented here consists of 10 children aged 3 or 4. The data available for each child are: # sex G or F whether their school is in a disused neighbourhood or not: O for yes, N for no. # Age in years and months at the date of the visit (two variables, one for the number of years, one for the number of months). #Weight in kilograms rounded to 100g. #The size in cm rounded to 0,5 cm near # Prénom Erika Célia Eric Eve Paul Jean Adam Louis Jules Léo #Sexe F F G F G G G G G G

Poids 16 14 13,5 15,4 16,5 16 17 14,8 17 16,7 An 3 3 3 4 3 4 3 3 4 3 Mois 5 10 5 0 8 0 11 9 1 3 Taille 100 97,0 95,5 101.0 100,0 98,5 103 98 101,5 100.0 #In statistics, it is very important to know the type of variables studied: quantitative, qualitative, ordinal… Clarify the situation in this case.

#1. Record data for each of the above variables in vectors you will name: Prenom, Sexe, Zep, Poids, An, Mois,Taille.

Prenom =c("Erika", "Célia"," Eric" ,"Eve"," Paul"," Jean", "Adam", "Louis", "Jules", "Léo")
Sexe=c("F ","F","G","F", "G", "G", "G", "G", "G", "G")
ZEP=c("O", "O", "O","O" ,"N", "O", "N", "O", "O", "O" )
Poids=c(16, 14, 13.5, 15.4, 16.5, 16, 17, 14.8, 17, 16.7)
An=c(3, 3, 3, 4, 3, 4, 3, 3, 4, 3)
Mois=c(5, 10, 5, 0, 8, 0, 11, 9, 1, 3)
Taille=c(100, 97.0, 95.5, 101.0, 100.0, 98.5, 103, 98, 101.5, 100.0)

#2. Average variables when possible. mean()

mean(Poids)
## [1] 15.69
mean(An)
## [1] 3.3
mean(Mois)
## [1] 5.2
mean(Taille)
## [1] 99.45

#3. Use the summary() function to obtain a statistical summary of the vectors you generated. This summary depends on the nature of the vector. Observe.

summary(data.frame(Poids,An,Mois,Taille,Prenom,Sexe,ZEP))
##      Poids             An            Mois           Taille      
##  Min.   :13.50   Min.   :3.00   Min.   : 0.00   Min.   : 95.50  
##  1st Qu.:14.95   1st Qu.:3.00   1st Qu.: 1.50   1st Qu.: 98.12  
##  Median :16.00   Median :3.00   Median : 5.00   Median :100.00  
##  Mean   :15.69   Mean   :3.30   Mean   : 5.20   Mean   : 99.45  
##  3rd Qu.:16.65   3rd Qu.:3.75   3rd Qu.: 8.75   3rd Qu.:100.75  
##  Max.   :17.00   Max.   :4.00   Max.   :11.00   Max.   :103.00  
##     Prenom              Sexe               ZEP           
##  Length:10          Length:10          Length:10         
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##                                                          
##                                                          
## 
#cbind ne peux pas contactener des elements hetrogènes
  1. Calculate the BMI of the individuals and group the obtained values into a vector that you will call BMI (the BMI is the quotient weight(in kg)/size 2(in m)).
BMI=c(1:10)
for( i in 1:10) {
  BMI[i]= Poids[i]   / (2*Taille[i]/100) } ; BMI
##  [1] 8.000000 7.216495 7.068063 7.623762 8.250000 8.121827 8.252427 7.551020
##  [9] 8.374384 8.350000
# car taille est en cm
  1. Group these variables into the table structure of R: data.frame().Plot the cloud of weight points based on height. Give a title to your graph, annotate the axes (parameters of the plot() function, see the help page ?plot())
Data=data.frame(Poids,An,Mois,Taille,Prenom,Sexe,ZEP, BMI)

plot(Data$Poids, Data$Taille, xlab="taille des enfans en cm", ylab="poids des enfant en kg", main=" cloud of weight 
points based on height")

6.Download the data Imcenfant.txt you will find on AMETICE into your R session with the command: D=read.table(file.choose(),sep=” t”,header=TRUE,dec=“,”);D;

D=read.table(file.choose(),sep="\t",header=TRUE,dec=",");D  # a quoi sert "\t"
##     SEXE zep poids an mois taille
## 1      F   O  16.0  3    5  100.0
## 2      F   O  14.0  3   10   97.0
## 3      G   O  13.5  3    5   95.5
## 4      F   O  15.4  4    0  101.0
## 5      G   N  16.5  3    8  100.0
## 6      G   O  16.0  4    0   98.5
## 7      G   N  17.0  3   11  103.0
## 8      G   O  14.8  3    9   98.0
## 9      G   O  17.0  4    1  101.5
## 10     G   O  16.7  3    3  100.0
## 11     G   O  15.5  3    7   98.5
## 12     G   O  15.0  3    9  101.0
## 13     G   O  14.5  3    9   94.0
## 14     F   N  16.8  4    0  103.0
## 15     F   O  16.2  4    1  101.5
## 16     F   O  14.7  3    9   98.5
## 17     F   O  16.5  4    1  103.0
## 18     G   O  15.1  3    9  100.0
## 19     G   O  15.0  4    0  101.0
## 20     G   O  15.5  4    1  103.0
## 21     F   O  15.0  4    6  102.0
## 22     G   O  16.8  3    5  101.5
## 23     G   O  19.8  3    7  107.5
## 24     G   O  15.5  3    9  104.5
## 25     F   O  17.8  4    1  100.0
## 26     F   O  16.0  4    3  102.0
## 27     F   O  15.2  3   10  103.5
## 28     F   O  18.6  3    9  100.0
## 29     G   O  16.0  4    2  109.0
## 30     G   O  18.0  4    1  106.0
## 31     G   N  17.5  3    6  102.5
## 32     G   O  16.5  4    3  104.0
## 33     F   O  14.8  4    1   97.0
## 34     G   O  18.4  4    3  106.0
## 35     G   O  17.6  4    2  107.5
## 36     G   O  18.8  3   10  107.5
## 37     G   O  16.0  4    1  100.0
## 38     G   O  18.5  3    6  107.0
## 39     F   O  14.6  3    8   95.0
## 40     F   O  14.7  3   10   97.0
## 41     F   O  10.5  3    8   88.5
## 42     F   N  15.2  3   11   97.0
## 43     F   O  15.5  3    6  101.0
## 44     F   O  14.5  4    0   96.0
## 45     F   O  16.0  4    3   98.0
## 46     G   O  16.0  4    3   99.0
## 47     G   O  13.0  4    0   95.5
## 48     F   O  15.0  3   10   98.0
## 49     G   O  15.8  3    7  101.0
## 50     F   O  13.6  4    4  101.0
## 51     G   O  17.7  3   10  104.0
## 52     F   N  14.8  3    8   97.0
## 53     G   O  18.8  4    0  103.0
## 54     G   O  17.5  4    0  105.5
## 55     F   O  16.2  4    1  105.5
## 56     G   O  17.6  3   10  104.5
## 57     F   O  17.4  3    6   96.5
## 58     G   O  15.0  3    3   98.0
## 59     G   O  22.0  3   11  107.0
## 60     F   O  17.0  3    2  103.0
## 61     G   O  14.5  3    4   98.0
## 62     F   O  16.0  3    9  103.0
## 63     G   O  12.7  3    9   95.0
## 64     G   O  19.0  3    7  111.5
## 65     F   O  16.0  4    0   99.5
## 66     F   O  14.5  3   10   94.0
## 67     G   N  17.3  4    1  104.0
## 68     F   O  12.0  3    3   90.5
## 69     G   O  13.3  3    7   95.0
## 70     F   O  16.7  3    4  100.0
## 71     F   O  18.0  3    9   99.0
## 72     F   O  16.6  3    4   98.0
## 73     F   O  17.0  3    4  100.0
## 74     G   O  19.0  3   10  100.0
## 75     F   O  16.0  3    3   98.0
## 76     G   N  17.2  3   11  105.5
## 77     F   O  17.0  3    4  100.5
## 78     F   O  15.0  3    9  100.0
## 79     G   O  17.6  3   10  105.0
## 80     F   O  17.6  4    0  102.5
## 81     G   O  15.0  3    3   98.0
## 82     G   O  15.0  3    6  101.0
## 83     F   O  14.0  3    5   97.0
## 84     F   O  14.5  3   11   94.5
## 85     F   N  18.0  3    6  101.0
## 86     F   O  16.8  3    6   93.0
## 87     G   O  14.5  3    2   92.0
## 88     G   O  17.0  3    3   99.0
## 89     G   O  19.0  3    4  107.0
## 90     F   O  18.0  3    3  100.0
## 91     F   O  12.0  3    2   90.0
## 92     G   O  17.5  3    7   97.0
## 93     G   O  17.4  4    0  101.0
## 94     F   O  15.8  3    9  103.0
## 95     G   O  17.5  3   10  103.0
## 96     G   O  15.5  3    9   97.0
## 97     G   O  14.5  3    2   95.5
## 98     F   O  15.7  3    9   97.5
## 99     F   O  19.0  3   10  109.0
## 100    F   O  22.8  3    9  106.0
## 101    G   O  22.0  4    4  107.5
## 102    G   O  16.4  3    7   99.0
## 103    G   O  18.7  3   10  109.5
## 104    G   O  16.0  4    3  104.5
## 105    F   N  17.0  4    3  105.0
## 106    G   O  16.0  3   10  101.0
## 107    G   O  16.3  4    3  103.0
## 108    F   O  19.0  4    1  103.0
## 109    F   O  19.4  4    5  108.0
## 110    F   O  15.0  3    9  100.0
## 111    F   O  15.5  3    9  100.5
## 112    G   O  15.0  3    4  100.0
## 113    F   O  19.4  3   10  106.0
## 114    F   O  15.7  4    0   97.5
## 115    F   N  15.2  3   10  102.0
## 116    G   O  18.0  3    9  101.0
## 117    G   N  15.5  3   10   99.0
## 118    G   N  19.0  3    9  106.0
## 119    F   N  17.3  4    5  104.5
## 120    G   N  18.0  3   10  105.0
## 121    F   N  15.0  3    7   99.0
## 122    F   N  16.0  3    8  101.0
## 123    F   N  14.5  3    8   91.0
## 124    G   N  13.5  3    2   96.2
## 125    G   O  16.5  3    8  102.5
## 126    F   O  14.0  3    7  100.0
## 127    G   N  18.0  4    3  107.0
## 128    F   N  14.8  4    0  102.5
## 129    G   N  15.0  3    8   97.0
## 130    G   N  16.0  4    3  105.0
## 131    G   O  18.5  3    5  104.0
## 132    F   N  15.5  4    3  104.0
## 133    F   O  15.5  3    9   96.5
## 134    G   N  13.0  3    3   92.0
## 135    G   N  17.5  3   10  101.0
## 136    G   O  18.7  3   10  104.0
## 137    G   N  17.0  4    3  101.0
## 138    G   N  16.5  3    1  101.0
## 139    G   N  16.5  3    8  103.0
## 140    G   N  15.8  3    7   98.0
## 141    F   N  15.9  4    0  105.0
## 142    G   N  19.6  4    3  108.5
## 143    F   N  16.5  3    9  100.0
## 144    F   N  14.0  3   11  101.0
## 145    G   N  13.7  3    2   96.0
## 146    F   O  19.5  3    8  101.0
## 147    G   N  12.0  4    2   95.0
## 148    G   N  17.0  3    9  101.5
## 149    G   N  17.0  3    6   99.0
## 150    F   N  14.3  3    4   98.0
## 151    F   N  17.8  3   11  105.5
## 152    F   N  15.7  3    7   98.5
  1. What information is obtained by dim(D)? colnames(D)? rownames(D)? What is the colnames(D) object type ?
dim(D) ; colnames(D) ; rownames(D) ; class(colnames(D))
## [1] 152   6
## [1] "SEXE"   "zep"    "poids"  "an"     "mois"   "taille"
##   [1] "1"   "2"   "3"   "4"   "5"   "6"   "7"   "8"   "9"   "10"  "11"  "12" 
##  [13] "13"  "14"  "15"  "16"  "17"  "18"  "19"  "20"  "21"  "22"  "23"  "24" 
##  [25] "25"  "26"  "27"  "28"  "29"  "30"  "31"  "32"  "33"  "34"  "35"  "36" 
##  [37] "37"  "38"  "39"  "40"  "41"  "42"  "43"  "44"  "45"  "46"  "47"  "48" 
##  [49] "49"  "50"  "51"  "52"  "53"  "54"  "55"  "56"  "57"  "58"  "59"  "60" 
##  [61] "61"  "62"  "63"  "64"  "65"  "66"  "67"  "68"  "69"  "70"  "71"  "72" 
##  [73] "73"  "74"  "75"  "76"  "77"  "78"  "79"  "80"  "81"  "82"  "83"  "84" 
##  [85] "85"  "86"  "87"  "88"  "89"  "90"  "91"  "92"  "93"  "94"  "95"  "96" 
##  [97] "97"  "98"  "99"  "100" "101" "102" "103" "104" "105" "106" "107" "108"
## [109] "109" "110" "111" "112" "113" "114" "115" "116" "117" "118" "119" "120"
## [121] "121" "122" "123" "124" "125" "126" "127" "128" "129" "130" "131" "132"
## [133] "133" "134" "135" "136" "137" "138" "139" "140" "141" "142" "143" "144"
## [145] "145" "146" "147" "148" "149" "150" "151" "152"
## [1] "character"
  1. Generate a string vector named Individus containing the following strings: person 1 , person 2,…,person 152 We will use the paste() and : functions.
Individus <- paste("person", 1:152, sep = " "); Individus
##   [1] "person 1"   "person 2"   "person 3"   "person 4"   "person 5"  
##   [6] "person 6"   "person 7"   "person 8"   "person 9"   "person 10" 
##  [11] "person 11"  "person 12"  "person 13"  "person 14"  "person 15" 
##  [16] "person 16"  "person 17"  "person 18"  "person 19"  "person 20" 
##  [21] "person 21"  "person 22"  "person 23"  "person 24"  "person 25" 
##  [26] "person 26"  "person 27"  "person 28"  "person 29"  "person 30" 
##  [31] "person 31"  "person 32"  "person 33"  "person 34"  "person 35" 
##  [36] "person 36"  "person 37"  "person 38"  "person 39"  "person 40" 
##  [41] "person 41"  "person 42"  "person 43"  "person 44"  "person 45" 
##  [46] "person 46"  "person 47"  "person 48"  "person 49"  "person 50" 
##  [51] "person 51"  "person 52"  "person 53"  "person 54"  "person 55" 
##  [56] "person 56"  "person 57"  "person 58"  "person 59"  "person 60" 
##  [61] "person 61"  "person 62"  "person 63"  "person 64"  "person 65" 
##  [66] "person 66"  "person 67"  "person 68"  "person 69"  "person 70" 
##  [71] "person 71"  "person 72"  "person 73"  "person 74"  "person 75" 
##  [76] "person 76"  "person 77"  "person 78"  "person 79"  "person 80" 
##  [81] "person 81"  "person 82"  "person 83"  "person 84"  "person 85" 
##  [86] "person 86"  "person 87"  "person 88"  "person 89"  "person 90" 
##  [91] "person 91"  "person 92"  "person 93"  "person 94"  "person 95" 
##  [96] "person 96"  "person 97"  "person 98"  "person 99"  "person 100"
## [101] "person 101" "person 102" "person 103" "person 104" "person 105"
## [106] "person 106" "person 107" "person 108" "person 109" "person 110"
## [111] "person 111" "person 112" "person 113" "person 114" "person 115"
## [116] "person 116" "person 117" "person 118" "person 119" "person 120"
## [121] "person 121" "person 122" "person 123" "person 124" "person 125"
## [126] "person 126" "person 127" "person 128" "person 129" "person 130"
## [131] "person 131" "person 132" "person 133" "person 134" "person 135"
## [136] "person 136" "person 137" "person 138" "person 139" "person 140"
## [141] "person 141" "person 142" "person 143" "person 144" "person 145"
## [146] "person 146" "person 147" "person 148" "person 149" "person 150"
## [151] "person 151" "person 152"
  1. Change the column names of your array with the command colnames(D)=Individus (Vector created previously) (YOU WANTED TO SAKED TO CHANGE the LINE ???)
rownames(D)=Individus ; D
##            SEXE zep poids an mois taille
## person 1      F   O  16.0  3    5  100.0
## person 2      F   O  14.0  3   10   97.0
## person 3      G   O  13.5  3    5   95.5
## person 4      F   O  15.4  4    0  101.0
## person 5      G   N  16.5  3    8  100.0
## person 6      G   O  16.0  4    0   98.5
## person 7      G   N  17.0  3   11  103.0
## person 8      G   O  14.8  3    9   98.0
## person 9      G   O  17.0  4    1  101.5
## person 10     G   O  16.7  3    3  100.0
## person 11     G   O  15.5  3    7   98.5
## person 12     G   O  15.0  3    9  101.0
## person 13     G   O  14.5  3    9   94.0
## person 14     F   N  16.8  4    0  103.0
## person 15     F   O  16.2  4    1  101.5
## person 16     F   O  14.7  3    9   98.5
## person 17     F   O  16.5  4    1  103.0
## person 18     G   O  15.1  3    9  100.0
## person 19     G   O  15.0  4    0  101.0
## person 20     G   O  15.5  4    1  103.0
## person 21     F   O  15.0  4    6  102.0
## person 22     G   O  16.8  3    5  101.5
## person 23     G   O  19.8  3    7  107.5
## person 24     G   O  15.5  3    9  104.5
## person 25     F   O  17.8  4    1  100.0
## person 26     F   O  16.0  4    3  102.0
## person 27     F   O  15.2  3   10  103.5
## person 28     F   O  18.6  3    9  100.0
## person 29     G   O  16.0  4    2  109.0
## person 30     G   O  18.0  4    1  106.0
## person 31     G   N  17.5  3    6  102.5
## person 32     G   O  16.5  4    3  104.0
## person 33     F   O  14.8  4    1   97.0
## person 34     G   O  18.4  4    3  106.0
## person 35     G   O  17.6  4    2  107.5
## person 36     G   O  18.8  3   10  107.5
## person 37     G   O  16.0  4    1  100.0
## person 38     G   O  18.5  3    6  107.0
## person 39     F   O  14.6  3    8   95.0
## person 40     F   O  14.7  3   10   97.0
## person 41     F   O  10.5  3    8   88.5
## person 42     F   N  15.2  3   11   97.0
## person 43     F   O  15.5  3    6  101.0
## person 44     F   O  14.5  4    0   96.0
## person 45     F   O  16.0  4    3   98.0
## person 46     G   O  16.0  4    3   99.0
## person 47     G   O  13.0  4    0   95.5
## person 48     F   O  15.0  3   10   98.0
## person 49     G   O  15.8  3    7  101.0
## person 50     F   O  13.6  4    4  101.0
## person 51     G   O  17.7  3   10  104.0
## person 52     F   N  14.8  3    8   97.0
## person 53     G   O  18.8  4    0  103.0
## person 54     G   O  17.5  4    0  105.5
## person 55     F   O  16.2  4    1  105.5
## person 56     G   O  17.6  3   10  104.5
## person 57     F   O  17.4  3    6   96.5
## person 58     G   O  15.0  3    3   98.0
## person 59     G   O  22.0  3   11  107.0
## person 60     F   O  17.0  3    2  103.0
## person 61     G   O  14.5  3    4   98.0
## person 62     F   O  16.0  3    9  103.0
## person 63     G   O  12.7  3    9   95.0
## person 64     G   O  19.0  3    7  111.5
## person 65     F   O  16.0  4    0   99.5
## person 66     F   O  14.5  3   10   94.0
## person 67     G   N  17.3  4    1  104.0
## person 68     F   O  12.0  3    3   90.5
## person 69     G   O  13.3  3    7   95.0
## person 70     F   O  16.7  3    4  100.0
## person 71     F   O  18.0  3    9   99.0
## person 72     F   O  16.6  3    4   98.0
## person 73     F   O  17.0  3    4  100.0
## person 74     G   O  19.0  3   10  100.0
## person 75     F   O  16.0  3    3   98.0
## person 76     G   N  17.2  3   11  105.5
## person 77     F   O  17.0  3    4  100.5
## person 78     F   O  15.0  3    9  100.0
## person 79     G   O  17.6  3   10  105.0
## person 80     F   O  17.6  4    0  102.5
## person 81     G   O  15.0  3    3   98.0
## person 82     G   O  15.0  3    6  101.0
## person 83     F   O  14.0  3    5   97.0
## person 84     F   O  14.5  3   11   94.5
## person 85     F   N  18.0  3    6  101.0
## person 86     F   O  16.8  3    6   93.0
## person 87     G   O  14.5  3    2   92.0
## person 88     G   O  17.0  3    3   99.0
## person 89     G   O  19.0  3    4  107.0
## person 90     F   O  18.0  3    3  100.0
## person 91     F   O  12.0  3    2   90.0
## person 92     G   O  17.5  3    7   97.0
## person 93     G   O  17.4  4    0  101.0
## person 94     F   O  15.8  3    9  103.0
## person 95     G   O  17.5  3   10  103.0
## person 96     G   O  15.5  3    9   97.0
## person 97     G   O  14.5  3    2   95.5
## person 98     F   O  15.7  3    9   97.5
## person 99     F   O  19.0  3   10  109.0
## person 100    F   O  22.8  3    9  106.0
## person 101    G   O  22.0  4    4  107.5
## person 102    G   O  16.4  3    7   99.0
## person 103    G   O  18.7  3   10  109.5
## person 104    G   O  16.0  4    3  104.5
## person 105    F   N  17.0  4    3  105.0
## person 106    G   O  16.0  3   10  101.0
## person 107    G   O  16.3  4    3  103.0
## person 108    F   O  19.0  4    1  103.0
## person 109    F   O  19.4  4    5  108.0
## person 110    F   O  15.0  3    9  100.0
## person 111    F   O  15.5  3    9  100.5
## person 112    G   O  15.0  3    4  100.0
## person 113    F   O  19.4  3   10  106.0
## person 114    F   O  15.7  4    0   97.5
## person 115    F   N  15.2  3   10  102.0
## person 116    G   O  18.0  3    9  101.0
## person 117    G   N  15.5  3   10   99.0
## person 118    G   N  19.0  3    9  106.0
## person 119    F   N  17.3  4    5  104.5
## person 120    G   N  18.0  3   10  105.0
## person 121    F   N  15.0  3    7   99.0
## person 122    F   N  16.0  3    8  101.0
## person 123    F   N  14.5  3    8   91.0
## person 124    G   N  13.5  3    2   96.2
## person 125    G   O  16.5  3    8  102.5
## person 126    F   O  14.0  3    7  100.0
## person 127    G   N  18.0  4    3  107.0
## person 128    F   N  14.8  4    0  102.5
## person 129    G   N  15.0  3    8   97.0
## person 130    G   N  16.0  4    3  105.0
## person 131    G   O  18.5  3    5  104.0
## person 132    F   N  15.5  4    3  104.0
## person 133    F   O  15.5  3    9   96.5
## person 134    G   N  13.0  3    3   92.0
## person 135    G   N  17.5  3   10  101.0
## person 136    G   O  18.7  3   10  104.0
## person 137    G   N  17.0  4    3  101.0
## person 138    G   N  16.5  3    1  101.0
## person 139    G   N  16.5  3    8  103.0
## person 140    G   N  15.8  3    7   98.0
## person 141    F   N  15.9  4    0  105.0
## person 142    G   N  19.6  4    3  108.5
## person 143    F   N  16.5  3    9  100.0
## person 144    F   N  14.0  3   11  101.0
## person 145    G   N  13.7  3    2   96.0
## person 146    F   O  19.5  3    8  101.0
## person 147    G   N  12.0  4    2   95.0
## person 148    G   N  17.0  3    9  101.5
## person 149    G   N  17.0  3    6   99.0
## person 150    F   N  14.3  3    4   98.0
## person 151    F   N  17.8  3   11  105.5
## person 152    F   N  15.7  3    7   98.5
  1. Use the summary() function to obtain a statistical summary of the different columns in
summary(D$SEXE) ; summary(D$taille) ; summary(D$zep) ; summary(D$poids) ; summary(D$an) ;  summary(D$mois)
##    Length     Class      Mode 
##       152 character character
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    88.5    98.0   101.0   100.7   103.6   111.5
##    Length     Class      Mode 
##       152 character character
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   10.50   15.00   16.00   16.28   17.50   22.80
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   3.000   3.000   3.000   3.303   4.000   4.000
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.000   3.000   6.000   5.618   9.000  11.000
  1. Do the same by replacing the summary function with the boxplot function. What do you get?
 boxplot(D$poids); boxplot(D$an);  boxplot(D$mois); boxplot(D$taille)

# ne fonctionne  pas pr varuable nn numerique 
  1. What is obtained by the commands summary(D), boxplot(D)?
#summary(D); boxplot(D) RETIRER POUR COMPILATION
# we get summury of each coloumn, but botplox(d) does not work as it stop working when he encounter a columns with a qualitativ variable

4.Exercise 1. Download bosson.csv, declare it as Bosson. Read data description. Assign column country to variable C, column gender to variable G, column aneurysm to variable A, column bmi to variable B, column risk to variable R. Are the five variables quantitatives, qualitative, discrete, continuous

D=read.csv(choose.files(), header=TRUE, sep=";") ; D
##     country gender aneurysm    bmi risk
## 1   Vietnam      M       21 21.094    0
## 2   Vietnam      M       27 19.031    0
## 3   Vietnam      M       28 20.313    0
## 4   Vietnam      F       33 17.778    0
## 5    France      F       34 21.604    0
## 6   Vietnam      F       35 21.096    0
## 7   Vietnam      F       35 17.778    0
## 8    France      M       35 22.583    0
## 9   Vietnam      F       37 21.914    0
## 10   France      F       39 24.035    0
## 11   France      F       39 24.035    0
## 12  Vietnam      F       40 13.333    0
## 13  Vietnam      F       43 19.477    0
## 14   France      M       43 26.675    0
## 15   France      M       44 21.857    0
## 16  Vietnam      M       44 23.438    0
## 17  Vietnam      M       44 23.875    0
## 18  Vietnam      M       46 18.365    0
## 19  Vietnam      M       47 22.232    0
## 20  Vietnam      M       47 16.947    0
## 21  Vietnam      F       47 21.094    0
## 22   France      F       48 25.911    0
## 23  Vietnam      M       48 20.576    0
## 24  Vietnam      F       50 16.649    0
## 25   France      M       51 25.763    0
## 26  Vietnam      F       52 17.710    0
## 27   France      M       52 24.152    0
## 28   France      M       53 24.302    0
## 29   France      M       53 26.990    0
## 30  Vietnam      M       56 22.862    0
## 31   France      M       59 24.344    0
## 32   France      M       60 26.219    0
## 33   France      M       61 18.685    0
## 34   France      M       63 26.174    0
## 35   France      M       65 23.548    0
## 36  Vietnam      F       65 15.111    0
## 37  Vietnam      F       87 18.750    0
## 38  Vietnam      F      102 23.922    0
## 39   France      M       49 17.823    0
## 40  Vietnam      M       43 22.206    0
## 41  Vietnam      M       21 16.406    1
## 42  Vietnam      F       25 17.778    1
## 43  Vietnam      F       25 16.004    1
## 44  Vietnam      F       28 19.531    1
## 45  Vietnam      F       29 20.313    1
## 46  Vietnam      M       29 22.206    1
## 47  Vietnam      M       31 20.812    1
## 48  Vietnam      M       32 19.111    1
## 49  Vietnam      M       32 19.111    1
## 50  Vietnam      M       33 21.094    1
## 51  Vietnam      F       34 27.344    1
## 52  Vietnam      M       34 20.313    1
## 53  Vietnam      F       34 17.567    1
## 54  Vietnam      M       34 21.094    1
## 55   France      F       35 24.005    1
## 56  Vietnam      M       35 19.228    1
## 57  Vietnam      F       35 19.835    1
## 58  Vietnam      M       35 23.661    1
## 59  Vietnam      F       36 18.667    1
## 60  Vietnam      M       36 18.929    1
## 61   France      F       36 25.481    1
## 62  Vietnam      F       37 20.776    1
## 63  Vietnam      M       37 17.087    1
## 64  Vietnam      M       37 19.814    1
## 65   France      M       38 26.366    1
## 66  Vietnam      M       39 18.591    1
## 67   France      M       40 22.724    1
## 68   France      M       40 21.952    1
## 69   France      M       41 24.913    1
## 70  Vietnam      M       41 20.957    1
## 71  Vietnam      M       41 18.750    1
## 72  Vietnam      M       42 18.359    1
## 73  Vietnam      M       42 26.673    1
## 74  Vietnam      F       42 18.491    1
## 75  Vietnam      F       42 20.761    1
## 76   France      M       42 24.221    1
## 77  Vietnam      M       43 24.035    1
## 78  Vietnam      M       43 21.875    1
## 79  Vietnam      M       43 22.039    1
## 80   France      F       43 29.395    1
## 81   France      M       44 26.563    1
## 82  Vietnam      F       45 15.427    1
## 83  Vietnam      M       45 19.531    1
## 84   France      M       46 24.897    1
## 85   France      M       46 25.344    1
## 86  Vietnam      M       46 19.487    1
## 87  Vietnam      F       47 19.141    1
## 88  Vietnam      M       47 23.438    1
## 89   France      M       48 25.909    1
## 90   France      M       49 26.366    1
## 91   France      M       50 21.799    1
## 92  Vietnam      F       51 18.750    1
## 93  Vietnam      F       52 18.975    1
## 94  Vietnam      M       52 17.857    1
## 95  Vietnam      M       52 17.857    1
## 96  Vietnam      F       52 19.837    1
## 97  Vietnam      M       53 16.228    1
## 98   France      M       55 24.465    1
## 99   France      M       55 26.573    1
## 100 Vietnam      M       55 22.491    1
## 101  France      M       58 26.563    1
## 102  France      M       58 25.393    1
## 103  France      M       59 22.985    1
## 104  France      M       59 22.395    1
## 105  France      M       60 20.988    1
## 106 Vietnam      M       60 22.491    1
## 107  France      M       60 28.408    1
## 108 Vietnam      F       62 19.694    1
## 109  France      F       62 21.231    1
## 110 Vietnam      M       62 21.504    1
## 111 Vietnam      M       65 16.529    1
## 112  France      M       65 26.730    1
## 113  France      F       65 28.345    1
## 114 Vietnam      M       67 19.100    1
## 115 Vietnam      F       70 15.582    1
## 116  France      F       72 26.610    1
## 117  France      F       72 26.563    1
## 118 Vietnam      F       78 17.425    1
## 119  France      M       80 29.297    1
## 120  France      M       82 18.070    1
## 121 Vietnam      F       74 18.975    1
## 122 Vietnam      M       26 18.730    2
## 123  France      M       27 26.927    2
## 124 Vietnam      M       27 19.031    2
## 125 Vietnam      M       30 16.406    2
## 126  France      M       30 25.594    2
## 127  France      M       30 25.100    2
## 128 Vietnam      M       30 22.206    2
## 129 Vietnam      M       32 14.533    2
## 130 Vietnam      M       32 22.206    2
## 131 Vietnam      F       33 15.556    2
## 132  France      M       33 26.795    2
## 133 Vietnam      F       36 27.111    2
## 134 Vietnam      M       36 17.782    2
## 135  France      F       38 20.077    2
## 136 Vietnam      M       39 17.993    2
## 137  France      F       40 25.469    2
## 138 Vietnam      M       40 22.206    2
## 139  France      M       40 31.378    2
## 140  France      M       41 23.735    2
## 141 Vietnam      M       41 21.338    2
## 142 Vietnam      M       42 18.365    2
## 143  France      M       43 27.380    2
## 144 Vietnam      M       43 18.809    2
## 145 Vietnam      M       44 16.327    2
## 146 Vietnam      M       44 22.206    2
## 147  France      M       44 23.739    2
## 148  France      M       44 29.066    2
## 149  France      M       44 26.704    2
## 150 Vietnam      F       44 20.812    2
## 151  France      M       45 33.081    2
## 152  France      M       47 28.732    2
## 153  France      M       47 23.939    2
## 154 Vietnam      F       47 17.010    2
## 155 Vietnam      M       47 14.984    2
## 156 Vietnam      M       48 20.029    2
## 157  France      M       48 24.772    2
## 158  France      F       48 27.344    2
## 159  France      M       48 26.563    2
## 160 Vietnam      M       48 19.031    2
## 161 Vietnam      M       48 27.344    2
## 162  France      M       49 36.157    2
## 163  France      F       51 20.830    2
## 164 Vietnam      M       52 22.308    2
## 165  France      M       52 27.054    2
## 166 Vietnam      M       53 22.206    2
## 167  France      M       53 25.952    2
## 168 Vietnam      M       54 20.173    2
## 169 Vietnam      M       55 22.039    2
## 170 Vietnam      M       55 21.094    2
## 171  France      M       56 26.398    2
## 172  France      M       56 23.671    2
## 173  France      M       57 27.682    2
## 174  France      M       59 24.447    2
## 175  France      M       60 29.727    2
## 176  France      M       62 31.834    2
## 177  France      M       65 30.247    2
## 178 Vietnam      M       68 21.259    2
## 179  France      M       74 22.790    2
## 180  France      M       85 33.897    2
## 181  France      M       90 21.830    2
## 182 Vietnam      M       54 22.206    2
## 183 Vietnam      M       29 14.568    3
## 184 Vietnam      M       30 22.206    3
## 185 Vietnam      M       32 20.196    3
## 186 Vietnam      M       32 22.206    3
## 187  France      M       41 29.385    3
## 188 Vietnam      M       41 20.761    3
## 189  France      M       46 29.412    3
## 190  France      M       47 26.730    3
## 191  France      M       48 21.535    3
## 192  France      M       49 31.179    3
## 193  France      M       50 21.605    3
## 194  France      M       50 22.491    3
## 195  France      M       51 25.766    3
## 196 Vietnam      M       53 24.802    3
## 197  France      M       58 26.563    3
## 198  France      M       58 31.637    3
## 199  France      M       58 27.414    3
## 200  France      M       60 29.321    3
## 201  France      M       65 26.704    3
## 202  France      M       70 29.070    3
## 203  France      M       80 27.143    3
## 204  France      M       36 29.758    3
## 205  France      M       30 29.411    4
## 206  France      M       50 32.000    4
## 207  France      M       67 27.084    4
## 208  France      M       75 27.441    4
## 209  France      M       35 28.056    5
# columne country qualitative discretes
# gender  qualitative discretes
# aneursym and bmi ae quantitative continue and
#rsik is quantitatie discrete
  1. Display the first 6 rows. Display the data for rows 28,34,78, and columns 2,4. Display the data for Vietnamese patients. Display the body mass index of men.
D
##     country gender aneurysm    bmi risk
## 1   Vietnam      M       21 21.094    0
## 2   Vietnam      M       27 19.031    0
## 3   Vietnam      M       28 20.313    0
## 4   Vietnam      F       33 17.778    0
## 5    France      F       34 21.604    0
## 6   Vietnam      F       35 21.096    0
## 7   Vietnam      F       35 17.778    0
## 8    France      M       35 22.583    0
## 9   Vietnam      F       37 21.914    0
## 10   France      F       39 24.035    0
## 11   France      F       39 24.035    0
## 12  Vietnam      F       40 13.333    0
## 13  Vietnam      F       43 19.477    0
## 14   France      M       43 26.675    0
## 15   France      M       44 21.857    0
## 16  Vietnam      M       44 23.438    0
## 17  Vietnam      M       44 23.875    0
## 18  Vietnam      M       46 18.365    0
## 19  Vietnam      M       47 22.232    0
## 20  Vietnam      M       47 16.947    0
## 21  Vietnam      F       47 21.094    0
## 22   France      F       48 25.911    0
## 23  Vietnam      M       48 20.576    0
## 24  Vietnam      F       50 16.649    0
## 25   France      M       51 25.763    0
## 26  Vietnam      F       52 17.710    0
## 27   France      M       52 24.152    0
## 28   France      M       53 24.302    0
## 29   France      M       53 26.990    0
## 30  Vietnam      M       56 22.862    0
## 31   France      M       59 24.344    0
## 32   France      M       60 26.219    0
## 33   France      M       61 18.685    0
## 34   France      M       63 26.174    0
## 35   France      M       65 23.548    0
## 36  Vietnam      F       65 15.111    0
## 37  Vietnam      F       87 18.750    0
## 38  Vietnam      F      102 23.922    0
## 39   France      M       49 17.823    0
## 40  Vietnam      M       43 22.206    0
## 41  Vietnam      M       21 16.406    1
## 42  Vietnam      F       25 17.778    1
## 43  Vietnam      F       25 16.004    1
## 44  Vietnam      F       28 19.531    1
## 45  Vietnam      F       29 20.313    1
## 46  Vietnam      M       29 22.206    1
## 47  Vietnam      M       31 20.812    1
## 48  Vietnam      M       32 19.111    1
## 49  Vietnam      M       32 19.111    1
## 50  Vietnam      M       33 21.094    1
## 51  Vietnam      F       34 27.344    1
## 52  Vietnam      M       34 20.313    1
## 53  Vietnam      F       34 17.567    1
## 54  Vietnam      M       34 21.094    1
## 55   France      F       35 24.005    1
## 56  Vietnam      M       35 19.228    1
## 57  Vietnam      F       35 19.835    1
## 58  Vietnam      M       35 23.661    1
## 59  Vietnam      F       36 18.667    1
## 60  Vietnam      M       36 18.929    1
## 61   France      F       36 25.481    1
## 62  Vietnam      F       37 20.776    1
## 63  Vietnam      M       37 17.087    1
## 64  Vietnam      M       37 19.814    1
## 65   France      M       38 26.366    1
## 66  Vietnam      M       39 18.591    1
## 67   France      M       40 22.724    1
## 68   France      M       40 21.952    1
## 69   France      M       41 24.913    1
## 70  Vietnam      M       41 20.957    1
## 71  Vietnam      M       41 18.750    1
## 72  Vietnam      M       42 18.359    1
## 73  Vietnam      M       42 26.673    1
## 74  Vietnam      F       42 18.491    1
## 75  Vietnam      F       42 20.761    1
## 76   France      M       42 24.221    1
## 77  Vietnam      M       43 24.035    1
## 78  Vietnam      M       43 21.875    1
## 79  Vietnam      M       43 22.039    1
## 80   France      F       43 29.395    1
## 81   France      M       44 26.563    1
## 82  Vietnam      F       45 15.427    1
## 83  Vietnam      M       45 19.531    1
## 84   France      M       46 24.897    1
## 85   France      M       46 25.344    1
## 86  Vietnam      M       46 19.487    1
## 87  Vietnam      F       47 19.141    1
## 88  Vietnam      M       47 23.438    1
## 89   France      M       48 25.909    1
## 90   France      M       49 26.366    1
## 91   France      M       50 21.799    1
## 92  Vietnam      F       51 18.750    1
## 93  Vietnam      F       52 18.975    1
## 94  Vietnam      M       52 17.857    1
## 95  Vietnam      M       52 17.857    1
## 96  Vietnam      F       52 19.837    1
## 97  Vietnam      M       53 16.228    1
## 98   France      M       55 24.465    1
## 99   France      M       55 26.573    1
## 100 Vietnam      M       55 22.491    1
## 101  France      M       58 26.563    1
## 102  France      M       58 25.393    1
## 103  France      M       59 22.985    1
## 104  France      M       59 22.395    1
## 105  France      M       60 20.988    1
## 106 Vietnam      M       60 22.491    1
## 107  France      M       60 28.408    1
## 108 Vietnam      F       62 19.694    1
## 109  France      F       62 21.231    1
## 110 Vietnam      M       62 21.504    1
## 111 Vietnam      M       65 16.529    1
## 112  France      M       65 26.730    1
## 113  France      F       65 28.345    1
## 114 Vietnam      M       67 19.100    1
## 115 Vietnam      F       70 15.582    1
## 116  France      F       72 26.610    1
## 117  France      F       72 26.563    1
## 118 Vietnam      F       78 17.425    1
## 119  France      M       80 29.297    1
## 120  France      M       82 18.070    1
## 121 Vietnam      F       74 18.975    1
## 122 Vietnam      M       26 18.730    2
## 123  France      M       27 26.927    2
## 124 Vietnam      M       27 19.031    2
## 125 Vietnam      M       30 16.406    2
## 126  France      M       30 25.594    2
## 127  France      M       30 25.100    2
## 128 Vietnam      M       30 22.206    2
## 129 Vietnam      M       32 14.533    2
## 130 Vietnam      M       32 22.206    2
## 131 Vietnam      F       33 15.556    2
## 132  France      M       33 26.795    2
## 133 Vietnam      F       36 27.111    2
## 134 Vietnam      M       36 17.782    2
## 135  France      F       38 20.077    2
## 136 Vietnam      M       39 17.993    2
## 137  France      F       40 25.469    2
## 138 Vietnam      M       40 22.206    2
## 139  France      M       40 31.378    2
## 140  France      M       41 23.735    2
## 141 Vietnam      M       41 21.338    2
## 142 Vietnam      M       42 18.365    2
## 143  France      M       43 27.380    2
## 144 Vietnam      M       43 18.809    2
## 145 Vietnam      M       44 16.327    2
## 146 Vietnam      M       44 22.206    2
## 147  France      M       44 23.739    2
## 148  France      M       44 29.066    2
## 149  France      M       44 26.704    2
## 150 Vietnam      F       44 20.812    2
## 151  France      M       45 33.081    2
## 152  France      M       47 28.732    2
## 153  France      M       47 23.939    2
## 154 Vietnam      F       47 17.010    2
## 155 Vietnam      M       47 14.984    2
## 156 Vietnam      M       48 20.029    2
## 157  France      M       48 24.772    2
## 158  France      F       48 27.344    2
## 159  France      M       48 26.563    2
## 160 Vietnam      M       48 19.031    2
## 161 Vietnam      M       48 27.344    2
## 162  France      M       49 36.157    2
## 163  France      F       51 20.830    2
## 164 Vietnam      M       52 22.308    2
## 165  France      M       52 27.054    2
## 166 Vietnam      M       53 22.206    2
## 167  France      M       53 25.952    2
## 168 Vietnam      M       54 20.173    2
## 169 Vietnam      M       55 22.039    2
## 170 Vietnam      M       55 21.094    2
## 171  France      M       56 26.398    2
## 172  France      M       56 23.671    2
## 173  France      M       57 27.682    2
## 174  France      M       59 24.447    2
## 175  France      M       60 29.727    2
## 176  France      M       62 31.834    2
## 177  France      M       65 30.247    2
## 178 Vietnam      M       68 21.259    2
## 179  France      M       74 22.790    2
## 180  France      M       85 33.897    2
## 181  France      M       90 21.830    2
## 182 Vietnam      M       54 22.206    2
## 183 Vietnam      M       29 14.568    3
## 184 Vietnam      M       30 22.206    3
## 185 Vietnam      M       32 20.196    3
## 186 Vietnam      M       32 22.206    3
## 187  France      M       41 29.385    3
## 188 Vietnam      M       41 20.761    3
## 189  France      M       46 29.412    3
## 190  France      M       47 26.730    3
## 191  France      M       48 21.535    3
## 192  France      M       49 31.179    3
## 193  France      M       50 21.605    3
## 194  France      M       50 22.491    3
## 195  France      M       51 25.766    3
## 196 Vietnam      M       53 24.802    3
## 197  France      M       58 26.563    3
## 198  France      M       58 31.637    3
## 199  France      M       58 27.414    3
## 200  France      M       60 29.321    3
## 201  France      M       65 26.704    3
## 202  France      M       70 29.070    3
## 203  France      M       80 27.143    3
## 204  France      M       36 29.758    3
## 205  France      M       30 29.411    4
## 206  France      M       50 32.000    4
## 207  France      M       67 27.084    4
## 208  France      M       75 27.441    4
## 209  France      M       35 28.056    5
D[1:6, ]
##   country gender aneurysm    bmi risk
## 1 Vietnam      M       21 21.094    0
## 2 Vietnam      M       27 19.031    0
## 3 Vietnam      M       28 20.313    0
## 4 Vietnam      F       33 17.778    0
## 5  France      F       34 21.604    0
## 6 Vietnam      F       35 21.096    0
D[c(28, 34, 78), c(2, 4)]
##    gender    bmi
## 28      M 24.302
## 34      M 26.174
## 78      M 21.875
D[D$country == "Vietnam", ]
##     country gender aneurysm    bmi risk
## 1   Vietnam      M       21 21.094    0
## 2   Vietnam      M       27 19.031    0
## 3   Vietnam      M       28 20.313    0
## 4   Vietnam      F       33 17.778    0
## 6   Vietnam      F       35 21.096    0
## 7   Vietnam      F       35 17.778    0
## 9   Vietnam      F       37 21.914    0
## 12  Vietnam      F       40 13.333    0
## 13  Vietnam      F       43 19.477    0
## 16  Vietnam      M       44 23.438    0
## 17  Vietnam      M       44 23.875    0
## 18  Vietnam      M       46 18.365    0
## 19  Vietnam      M       47 22.232    0
## 20  Vietnam      M       47 16.947    0
## 21  Vietnam      F       47 21.094    0
## 23  Vietnam      M       48 20.576    0
## 24  Vietnam      F       50 16.649    0
## 26  Vietnam      F       52 17.710    0
## 30  Vietnam      M       56 22.862    0
## 36  Vietnam      F       65 15.111    0
## 37  Vietnam      F       87 18.750    0
## 38  Vietnam      F      102 23.922    0
## 40  Vietnam      M       43 22.206    0
## 41  Vietnam      M       21 16.406    1
## 42  Vietnam      F       25 17.778    1
## 43  Vietnam      F       25 16.004    1
## 44  Vietnam      F       28 19.531    1
## 45  Vietnam      F       29 20.313    1
## 46  Vietnam      M       29 22.206    1
## 47  Vietnam      M       31 20.812    1
## 48  Vietnam      M       32 19.111    1
## 49  Vietnam      M       32 19.111    1
## 50  Vietnam      M       33 21.094    1
## 51  Vietnam      F       34 27.344    1
## 52  Vietnam      M       34 20.313    1
## 53  Vietnam      F       34 17.567    1
## 54  Vietnam      M       34 21.094    1
## 56  Vietnam      M       35 19.228    1
## 57  Vietnam      F       35 19.835    1
## 58  Vietnam      M       35 23.661    1
## 59  Vietnam      F       36 18.667    1
## 60  Vietnam      M       36 18.929    1
## 62  Vietnam      F       37 20.776    1
## 63  Vietnam      M       37 17.087    1
## 64  Vietnam      M       37 19.814    1
## 66  Vietnam      M       39 18.591    1
## 70  Vietnam      M       41 20.957    1
## 71  Vietnam      M       41 18.750    1
## 72  Vietnam      M       42 18.359    1
## 73  Vietnam      M       42 26.673    1
## 74  Vietnam      F       42 18.491    1
## 75  Vietnam      F       42 20.761    1
## 77  Vietnam      M       43 24.035    1
## 78  Vietnam      M       43 21.875    1
## 79  Vietnam      M       43 22.039    1
## 82  Vietnam      F       45 15.427    1
## 83  Vietnam      M       45 19.531    1
## 86  Vietnam      M       46 19.487    1
## 87  Vietnam      F       47 19.141    1
## 88  Vietnam      M       47 23.438    1
## 92  Vietnam      F       51 18.750    1
## 93  Vietnam      F       52 18.975    1
## 94  Vietnam      M       52 17.857    1
## 95  Vietnam      M       52 17.857    1
## 96  Vietnam      F       52 19.837    1
## 97  Vietnam      M       53 16.228    1
## 100 Vietnam      M       55 22.491    1
## 106 Vietnam      M       60 22.491    1
## 108 Vietnam      F       62 19.694    1
## 110 Vietnam      M       62 21.504    1
## 111 Vietnam      M       65 16.529    1
## 114 Vietnam      M       67 19.100    1
## 115 Vietnam      F       70 15.582    1
## 118 Vietnam      F       78 17.425    1
## 121 Vietnam      F       74 18.975    1
## 122 Vietnam      M       26 18.730    2
## 124 Vietnam      M       27 19.031    2
## 125 Vietnam      M       30 16.406    2
## 128 Vietnam      M       30 22.206    2
## 129 Vietnam      M       32 14.533    2
## 130 Vietnam      M       32 22.206    2
## 131 Vietnam      F       33 15.556    2
## 133 Vietnam      F       36 27.111    2
## 134 Vietnam      M       36 17.782    2
## 136 Vietnam      M       39 17.993    2
## 138 Vietnam      M       40 22.206    2
## 141 Vietnam      M       41 21.338    2
## 142 Vietnam      M       42 18.365    2
## 144 Vietnam      M       43 18.809    2
## 145 Vietnam      M       44 16.327    2
## 146 Vietnam      M       44 22.206    2
## 150 Vietnam      F       44 20.812    2
## 154 Vietnam      F       47 17.010    2
## 155 Vietnam      M       47 14.984    2
## 156 Vietnam      M       48 20.029    2
## 160 Vietnam      M       48 19.031    2
## 161 Vietnam      M       48 27.344    2
## 164 Vietnam      M       52 22.308    2
## 166 Vietnam      M       53 22.206    2
## 168 Vietnam      M       54 20.173    2
## 169 Vietnam      M       55 22.039    2
## 170 Vietnam      M       55 21.094    2
## 178 Vietnam      M       68 21.259    2
## 182 Vietnam      M       54 22.206    2
## 183 Vietnam      M       29 14.568    3
## 184 Vietnam      M       30 22.206    3
## 185 Vietnam      M       32 20.196    3
## 186 Vietnam      M       32 22.206    3
## 188 Vietnam      M       41 20.761    3
## 196 Vietnam      M       53 24.802    3
# Display the body mass index of men
D[D$gender== "M", "bmi"] # selectione les lignes =="M" pour la sexe et ne prends que la colone bmi 
##   [1] 21.094 19.031 20.313 22.583 26.675 21.857 23.438 23.875 18.365 22.232
##  [11] 16.947 20.576 25.763 24.152 24.302 26.990 22.862 24.344 26.219 18.685
##  [21] 26.174 23.548 17.823 22.206 16.406 22.206 20.812 19.111 19.111 21.094
##  [31] 20.313 21.094 19.228 23.661 18.929 17.087 19.814 26.366 18.591 22.724
##  [41] 21.952 24.913 20.957 18.750 18.359 26.673 24.221 24.035 21.875 22.039
##  [51] 26.563 19.531 24.897 25.344 19.487 23.438 25.909 26.366 21.799 17.857
##  [61] 17.857 16.228 24.465 26.573 22.491 26.563 25.393 22.985 22.395 20.988
##  [71] 22.491 28.408 21.504 16.529 26.730 19.100 29.297 18.070 18.730 26.927
##  [81] 19.031 16.406 25.594 25.100 22.206 14.533 22.206 26.795 17.782 17.993
##  [91] 22.206 31.378 23.735 21.338 18.365 27.380 18.809 16.327 22.206 23.739
## [101] 29.066 26.704 33.081 28.732 23.939 14.984 20.029 24.772 26.563 19.031
## [111] 27.344 36.157 22.308 27.054 22.206 25.952 20.173 22.039 21.094 26.398
## [121] 23.671 27.682 24.447 29.727 31.834 30.247 21.259 22.790 33.897 21.830
## [131] 22.206 14.568 22.206 20.196 22.206 29.385 20.761 29.412 26.730 21.535
## [141] 31.179 21.605 22.491 25.766 24.802 26.563 31.637 27.414 29.321 26.704
## [151] 29.070 27.143 29.758 29.411 32.000 27.084 27.441 28.056
#D[,1:6] ; D[c(28,34,78), c(2,4)] celui la il ne fonctionne pas
# i guess c'est car comme les colonms ont un nom on ne peut pas les appeler 
  1. Compute the absolute and relative frequencies of the two countries.
# frequence absolue
freVietanm=length(D[D$country=="Vietnam",1]) ; freVietanm
## [1] 110
freFR=length(D[D$country=="France",1]) ; freFR
## [1] 99
# freq  relative
freVietanm=(length(D[D$country=="Vietnam",1])/209) ; freVietanm
## [1] 0.5263158
freFR=(length(D[D$country=="France",1])/209) ; freFR
## [1] 0.4736842

4.What proportion of patients are Vietnamese? Compute the absolute and relative frequencies of the two genders.

# % de patient vietnamiet
freVietanm=(length(D[D$country=="Vietnam",1])/209) ; freVietanm
## [1] 0.5263158
# freq absolut

length(D[D$gender == "M" & D$country == "Vietnam", 1])
## [1] 74
length(D[D$gender == "F" & D$country == "Vietnam", 1])
## [1] 36
#frequences homme vietnaimien malade fre relative sur l'ensemble de vietnamien
FqM.vi=( length(D[D$gender == "M" & D$country == "Vietnam", 1])) / (length(D[D$country=="Vietnam",1])); FqM.vi
## [1] 0.6727273
FqF.vi=( length(D[D$gender == "F" & D$country == "Vietnam", 1])) / (length(D[D$country=="Vietnam",1])); FqF.vi
## [1] 0.3272727

5.What proportion of patients are women? Compute the absolute and relative frequencies of the six risk levels.

#roportion of patients are women?

a=length(D[D$gender=="F",1])/length(D[,1]) ; print(" % de femme patient")
## [1] " % de femme patient"
# abslutr value and rlative frquence of eache risc
table(D$risk)
## 
##  0  1  2  3  4  5 
## 40 81 61 22  4  1
#prop.table(D$risk) does not work
length(D$risk)
## [1] 209
print(" tableau des frequences relative des risques :")
## [1] " tableau des frequences relative des risques :"
table(D$risk)/209
## 
##           0           1           2           3           4           5 
## 0.191387560 0.387559809 0.291866029 0.105263158 0.019138756 0.004784689

6.What proportion of patientshave at least two risk factors? Display bar plots for the three variables. ??? whhich one

print("proportion of patientshave at least two risk factors")
## [1] "proportion of patientshave at least two risk factors"
length(D[D$risk > 1 ,1])/length((D$risk))
## [1] 0.4210526
barplot(D$risk/209) ;

barplot(table(D$country)) # barplot ne sais gerer que les entréé numerique donc beosin de table avant

barplot(table(D$gender))

  1. Display bar plots for G per value of R and for R per value of G. How many men have 0 risk factor?
#barplot(table(D$gender); table(D$risk) )
#barplot(table(D$risk),table(D$risk))

# Supposons que "SEXE" est la colonne pour le genre et "R" est la colonne pour le risque
# Convertir la colonne "R" en facteur pour garantir que toutes les valeurs sont incluses dans le graphique
D$risk <- as.factor(D$risk)

# Tableau de contingence pour les proportions d'hommes et de femmes pour chaque valeur du risque
contingency_table <- table(D$risk, D$gender)
# Créer un graphique à barres
barplot(contingency_table, beside = TRUE, col = c("lightgray", "gray", "darkgray","darkblue","black"),
        legend.text = TRUE, args.legend = list(title = "risque"), main=" reparition des risques en fonction du genre")

D$gender=as.factor(D$gender)
CNTGtable=table(D$gender, D$risk)
barplot(CNTGtable,beside=TRUE, col=c("green","purple"), legend.text=TRUE, args.legend= list(title="gender"), main="rreparition des risques en fonction du genre")

  1. Display summary, boxplot, histogram, ecdf, for variable A.
summary(D$aneurysm) ; boxplot(D$aneurysm) ; hist(D$aneurysm,) 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   21.00   37.00   46.00   47.57   55.00  102.00

  1. Compute the mean, variance, standard-deviation, median, quantiles at 1/3 and 2/3, inter-quartile range of variable A.
A=summary(D$aneurysm) ; A
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   21.00   37.00   46.00   47.57   55.00  102.00
sd(D$aneurysm)
## [1] 13.76297
sd(D$aneurysm)^2
## [1] 189.4194
A[5]-A[2]
## 3rd Qu. 
##      18
  1. Assign to Az the z-scores of variable A (standardize). Repeat the previous question for variable Az. What are the differences with A?
# Utiliser la fonction scale pour standardiser les colonnes

B=scale(D$aneurysm); 
Az=summary(B) ; Az
##        V1         
##  Min.   :-1.9305  
##  1st Qu.:-0.7680  
##  Median :-0.1140  
##  Mean   : 0.0000  
##  3rd Qu.: 0.5399  
##  Max.   : 3.9549
sd(B)
## [1] 1
sd(B)^2
## [1] 1
Q=quantile(B) ;Q; Q[4]-Q[2]
##         0%        25%        50%        75%       100% 
## -1.9304969 -0.7679574 -0.1140290  0.5398995  3.9548591
##      75% 
## 1.307857
# differences, value are differences because theyr are centré et reduite mais l'information est la meme est est juste deviaisé de son effet echel

EN PLUS 5.Exercise 1. Upload ferretti.csv, read data description. Assign column height to variable H, column diameter to variable DA, column density to variable DE, column invasive to variable I. Sort the four variables as discrete or continuous.

DataF=D=read.csv(choose.files(), header=TRUE, sep=";"); DataF
##    height diameter  density invasive
## 1    23.0     18.7 negative       no
## 2    11.0     13.9 negative      yes
## 3    16.8     14.6 negative      yes
## 4     9.3      8.2 negative      yes
## 5     9.5     10.3 negative       no
## 6    17.0     18.1 negative      yes
## 7    13.5     12.2 negative      yes
## 8     7.7     10.5 negative      yes
## 9     7.0     10.0 negative       no
## 10    7.1     12.1 negative      yes
## 11   18.5     11.9 positive      yes
## 12   17.6     21.9 negative      yes
## 13   12.9     12.9 negative       no
## 14   11.1     11.0 negative       no
## 15    5.8      7.0 negative       no
## 16    4.8      5.7 negative       no
## 17   41.3     40.5 negative      yes
## 18   13.3     15.6 positive      yes
## 19    7.1     12.3 negative      yes
## 20   10.1     14.2 negative      yes
## 21   12.3     13.0 negative       no
## 22   13.4     24.3 negative       no
## 23   51.9     27.7 positive      yes
## 24    8.3      6.3 negative       no
## 25    9.0     12.9 negative       no
## 26   23.2     16.2 positive      yes
## 27   10.1     10.3 negative      yes
## 28   11.5     16.1 negative       no
## 29    8.2     11.0     null       no
## 30    7.3      6.4     null       no
## 31   24.5     25.7     null      yes
## 32   16.0     17.5 positive      yes
## 33    6.9     13.0     null      yes
## 34   15.8     16.8 positive      yes
## 35   16.5     14.5     null      yes
## 36   12.7     12.8     null      yes
## 37   15.4     22.8 positive      yes
## 38   12.3     11.7 positive      yes
## 39   10.0     17.6     null       no
## 40    7.3      9.7     null       no
## 41   11.9     10.9     null       no
## 42    9.5     11.7     null       no
## 43   11.9      7.6     null      yes
# Height abd diameyer are continious and deniste and invasiv are discrete
  1. Display the first 6 rows. Display the data for rows 10 to 15, and columns 2,4. Display the data for invasive tumors. Display the height of tumors having positive density.
DataF[c(1:6),] ; 
##   height diameter  density invasive
## 1   23.0     18.7 negative       no
## 2   11.0     13.9 negative      yes
## 3   16.8     14.6 negative      yes
## 4    9.3      8.2 negative      yes
## 5    9.5     10.3 negative       no
## 6   17.0     18.1 negative      yes
DataF[c(10:15), c(2 , 4)]
##    diameter invasive
## 10     12.1      yes
## 11     11.9      yes
## 12     21.9      yes
## 13     12.9       no
## 14     11.0       no
## 15      7.0       no
DataF[DataF$invasive=="yes", ]
##    height diameter  density invasive
## 2    11.0     13.9 negative      yes
## 3    16.8     14.6 negative      yes
## 4     9.3      8.2 negative      yes
## 6    17.0     18.1 negative      yes
## 7    13.5     12.2 negative      yes
## 8     7.7     10.5 negative      yes
## 10    7.1     12.1 negative      yes
## 11   18.5     11.9 positive      yes
## 12   17.6     21.9 negative      yes
## 17   41.3     40.5 negative      yes
## 18   13.3     15.6 positive      yes
## 19    7.1     12.3 negative      yes
## 20   10.1     14.2 negative      yes
## 23   51.9     27.7 positive      yes
## 26   23.2     16.2 positive      yes
## 27   10.1     10.3 negative      yes
## 31   24.5     25.7     null      yes
## 32   16.0     17.5 positive      yes
## 33    6.9     13.0     null      yes
## 34   15.8     16.8 positive      yes
## 35   16.5     14.5     null      yes
## 36   12.7     12.8     null      yes
## 37   15.4     22.8 positive      yes
## 38   12.3     11.7 positive      yes
## 43   11.9      7.6     null      yes
DataF[DataF$invasive=="yes", 1]
##  [1] 11.0 16.8  9.3 17.0 13.5  7.7  7.1 18.5 17.6 41.3 13.3  7.1 10.1 51.9 23.2
## [16] 10.1 24.5 16.0  6.9 15.8 16.5 12.7 15.4 12.3 11.9
  1. Compute the absolute and relative frequencies of the three classes of density. What is the proportion of tumors with positive density? Compute the absolute and relative frequencies of invasive and non-invasive. What is the proportion of invasive tumors? Display bar plots for the two variables.
table(DataF$density)
## 
## negative     null positive 
##       24       11        8
print("porportion of tumor with posotiv density")
## [1] "porportion of tumor with posotiv density"
length(DataF[DataF$density=="positive", 1])/ length(DataF[,1])
## [1] 0.1860465
DataF[,4]
##  [1] "no"  "yes" "yes" "yes" "no"  "yes" "yes" "yes" "no"  "yes" "yes" "yes"
## [13] "no"  "no"  "no"  "no"  "yes" "yes" "yes" "yes" "no"  "no"  "yes" "no" 
## [25] "no"  "yes" "yes" "no"  "no"  "no"  "yes" "yes" "yes" "yes" "yes" "yes"
## [37] "yes" "yes" "no"  "no"  "no"  "no"  "yes"
table(DataF[,4])
## 
##  no yes 
##  18  25
print( "relative frequencies of invasive and non-invasive"  )
## [1] "relative frequencies of invasive and non-invasive"
table(DataF[,4])/length(DataF[,1])
## 
##        no       yes 
## 0.4186047 0.5813953
barplot(table(DataF$density)) ; barplot(table(DataF$invasive))

  1. Display bar plots for DE per value of I and for I per value of DE. How many invasive tumors have positive density? What proportion of all tumors are invasive with positive density? What proportion among tumors with positive density are invasive? What proportion among invasive tumors have positive density?
DataF
##    height diameter  density invasive
## 1    23.0     18.7 negative       no
## 2    11.0     13.9 negative      yes
## 3    16.8     14.6 negative      yes
## 4     9.3      8.2 negative      yes
## 5     9.5     10.3 negative       no
## 6    17.0     18.1 negative      yes
## 7    13.5     12.2 negative      yes
## 8     7.7     10.5 negative      yes
## 9     7.0     10.0 negative       no
## 10    7.1     12.1 negative      yes
## 11   18.5     11.9 positive      yes
## 12   17.6     21.9 negative      yes
## 13   12.9     12.9 negative       no
## 14   11.1     11.0 negative       no
## 15    5.8      7.0 negative       no
## 16    4.8      5.7 negative       no
## 17   41.3     40.5 negative      yes
## 18   13.3     15.6 positive      yes
## 19    7.1     12.3 negative      yes
## 20   10.1     14.2 negative      yes
## 21   12.3     13.0 negative       no
## 22   13.4     24.3 negative       no
## 23   51.9     27.7 positive      yes
## 24    8.3      6.3 negative       no
## 25    9.0     12.9 negative       no
## 26   23.2     16.2 positive      yes
## 27   10.1     10.3 negative      yes
## 28   11.5     16.1 negative       no
## 29    8.2     11.0     null       no
## 30    7.3      6.4     null       no
## 31   24.5     25.7     null      yes
## 32   16.0     17.5 positive      yes
## 33    6.9     13.0     null      yes
## 34   15.8     16.8 positive      yes
## 35   16.5     14.5     null      yes
## 36   12.7     12.8     null      yes
## 37   15.4     22.8 positive      yes
## 38   12.3     11.7 positive      yes
## 39   10.0     17.6     null       no
## 40    7.3      9.7     null       no
## 41   11.9     10.9     null       no
## 42    9.5     11.7     null       no
## 43   11.9      7.6     null      yes
DataF$invasive=as.factor(DataF$invasive)
CNTGtable2=table( DataF$invasive, DataF$density)
barplot (CNTGtable2,col=c("red", "lightblue"), legend.text=TRUE, args.legend= list(title="invasiv"), main="reparition des densité en fonction du risk" )

DataF$density=as.factor(DataF$density)
CNTGtable2=table( DataF$density,  DataF$invasive)
barplot (CNTGtable2,col=c("red", "orange", "yellow"), legend.text=TRUE, args.legend= list(title="density"), main="reparition des densité en fonction du risk" )

  1. Exercise
  2. Upload tauber.csv, read data description. Assign column gender to variable G, column age to variable A, column height to variable H, column weight to variable W. Sort the four variables as discrete or continuous.
  3. Display summary, boxplot, histogram, ecdf, for variable A.
  4. Compute the mean, variance, standard-deviation, median, quantiles at 1/3 and 2/3, inter-quartile range.
  5. How many children are younger than 5 years? older than 6 years? What proportion of children are younger than 5 years, older than 6 years? What age is such that 10% of children are younger? What age is such that 10% of patients are older?
  6. On the boxplot of A, superpose a red horizontal line marking the mean, a blue horizontal line marking the median, two green horizontal lines marking the first and third quartiles.
  7. On the histogram of A, superpose a red vertical line marking the mean, a blue vertical line marking the median, two green vertical lines marking the first and third quartiles.
  8. On the ecdf plot of A, superpose a red vertical line marking the mean, a blue vertical line marking the median, two green vertical lines marking the first and third quartiles. Add a blue horizontal line at 0.5, two green horizontal lines at 0.25 and 0.75.
  9. Repeat questions 2. to 7. for variable H. For question 4, replace “younger than 5 years” and “older than 6” with “smaller than 1.10 meter” and “taller than 1.20 meter”.
  10. Repeat questions 2. to 7. for variable W. For question 4, replace “younger than 5” and “older than 6” with “lighter than 20 kilograms” and “heavier than 25 kilograms