--- title: "Boite à outils R" date: "`r Sys.Date()`" output: rmdformats::readthedown: highlight: kate --- ```{r setup, include=FALSE} library(knitr) library(rmdformats) ## Global options options(max.print="75") opts_chunk$set(echo=TRUE, cache=TRUE, prompt=FALSE, tidy=TRUE, comment=NA, message=FALSE, warning=FALSE, eval=FALSE, results="hide") opts_knit$set(width=75) ``` # Importations ## Importations multiples de fichiers csv ```{r} files_list <- list.files(here::here("data"),pattern = "*.csv") library(stringr) data_names <- str_remove(files_list, ".csv") for(i in 1: length(files_list)) { x <- read.csv2(here::here("data",files_list[i])) assign(data_names[i], x) } rm(x) ``` ## Importer plusieurs fichiers csv et les assembler ```{r} library(dplyr) library(purrr) mario_data <- list.files(path = "data2", full.names = TRUE) %>% set_names() %>% map_dfr(~ read.csv2(.x),.id="file_name") %>% mutate(file_name=str_remove(file_name, "data2/")) %>% mutate(file_name=str_remove(file_name, ".csv")) ``` # Statistiques ## Tests de normalité ```{r} apply(iris[,1:4],2, shapiro.test) ``` Pour ne retenir que la pvalue ```{r} pSW <- function(x) { p <-shapiro.test(x)$p.value return(p) } apply(iris[,1:4],2, pSW) ```