R Markdown

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

Including Plots

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.

# exo data frame 

#1
df1 <- data.frame(student_CACQ_Opex = sample(LETTERS, 13,replace = T),
                  taille = sample(160:190, 13),
                  poids = sample(60:85, 13))

#2
df1$Connaissance_de_R <- sample(1:5,13, replace = T)

#3
names(df1)
## [1] "student_CACQ_Opex" "taille"            "poids"            
## [4] "Connaissance_de_R"
#4
student_CACQ_Opex_maxt = df1$student_CACQ_Opex[df1$taille == max(df1$taille)]

#5
student_CACQ_Opex_maxp = df1$student_CACQ_Opex[df1$poids == max(df1$poids)]

#6
df1[df1$taille>165 & df1$poids > 75,]
##    student_CACQ_Opex taille poids Connaissance_de_R
## 2                  U    174    77                 4
## 9                  L    181    82                 1
## 11                 S    166    81                 5
## 12                 U    188    76                 3
#7
df1$Yves <- sample("yves",13, replace = T)
df1$Yves <- c("yves")
#les deux donne le meme resultat

#8
par = seq(1, nrow(df1))
df1$par = paste0("Per_", par)

#9
df1$bol = as.logical(df1$Connaissance_de_R >= 2.5)

print(df1)
##    student_CACQ_Opex taille poids Connaissance_de_R Yves    par   bol
## 1                  L    179    64                 4 yves  Per_1  TRUE
## 2                  U    174    77                 4 yves  Per_2  TRUE
## 3                  E    180    63                 4 yves  Per_3  TRUE
## 4                  D    183    60                 1 yves  Per_4 FALSE
## 5                  P    178    67                 4 yves  Per_5  TRUE
## 6                  C    167    71                 4 yves  Per_6  TRUE
## 7                  U    185    69                 3 yves  Per_7  TRUE
## 8                  D    184    75                 4 yves  Per_8  TRUE
## 9                  L    181    82                 1 yves  Per_9 FALSE
## 10                 X    182    68                 5 yves Per_10  TRUE
## 11                 S    166    81                 5 yves Per_11  TRUE
## 12                 U    188    76                 3 yves Per_12  TRUE
## 13                 K    161    79                 1 yves Per_13 FALSE
#exo matrice 

#1
x <- matrix(data = c(1000:1100,sample(40:50,101, replace = T)),nrow = 101, ncol = 2)

#2
colnames(x) <- c("Wavenumber","Intensity")

#3
dim(x)
## [1] 101   2
#4
x[,1]
##   [1] 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014
##  [16] 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029
##  [31] 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044
##  [46] 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059
##  [61] 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074
##  [76] 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089
##  [91] 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100
#5
x[1,1]
## Wavenumber 
##       1000
#6
rownames(x) <- paste("Spectre_", 1:101, sep = "")

#7
x <- subset(x, rownames(x) != "Spectre_35" & rownames(x) != "Spectre_46")
df <-  data.frame(x = sample(1:100),
                  y = sample(1:1000,100))
  
plot(df)