1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
num<-c(1:5)
Un <- c(3,"3W",10,5,5)
Deux<-c(5,10,5,3,1)
Trois<-c(4,4,4,4,3)
matrice <- matrix(c(num,Un,Deux,Trois), nrow=5, ncol=4)
# Nom des colonnes
colnames(matrice) <- c("Chiffre","Un","Deux", "Trois")
matrice
#i ou iW dans les colonnes un deux ou trois
matrice[which(apply(matrix(as.character(matrice[,1:3]) %in% c(i,paste(i,"W",sep="")) ,ncol=ncol(matrice[,1:3])),1,sum)>0),]
#enregistre
write.table (matrice, file = "TEST.csv", sep=",",row.names=FALSE, na="")
#efface mémoire
rm(list=ls())
#Lecture du fichier ou trouver les informations
echantillon<-read.csv("TEST.csv")
echantillon
i<-4
echantillon[which(apply(matrix(as.character(echantillon[,2:4]) %in% c(i,paste(i,"W",sep="")) ,ncol=ncol(echantillon[,2:4])),1,sum)>0),] |
Partager