load ("dept.rda") ls() dept col.ciep <- c(rgb(105/255,166/255,233/255),rgb(129/255,180/255,237/255), rgb(154/255,195/255,240/255),rgb(180/255,210/255,244/255), rgb(206/255,226/255,248/255),rgb(231/255,240/255,251/255)) col.blue <- rgb(0/255,78/255,162/255) sample(15) ?sample dept ?sample dept$dept[sample(1:95,15)] runif(15)*20 runif(15)*100 seq(5,300,length=15) round(seq(5,300,length=15)) set.seed(1234) xx <- cbind(dept$dept[sample(1:95,15)],round(seq(5,300,length=15))) xx map('france') map('france',regions=names(xx),add=T) leg.txt <- c("0-50","50-100","100-250","250+") legend("bottomleft",leg.txt,col=my.cols,pch=15,bty="n", title="Nb. candidats",cex=.7) title(main="Résultats erronés") library(maps) map('france') map('france',regions=names(xx),add=T) leg.txt <- c("0-50","50-100","100-250","250+") legend("bottomleft",leg.txt,col=my.cols,pch=15,bty="n", title="Nb. candidats",cex=.7) title(main="Résultats erronés") my.cols <- c(rgb(231/255,240/255,251/255),rgb(180/255,210/255,244/255), rgb(129/255,180/255,237/255),rgb(0/255,78/255,162/255)) map('france') map('france',regions=names(xx),add=T) leg.txt <- c("0-50","50-100","100-250","250+") legend("bottomleft",leg.txt,col=my.cols,pch=15,bty="n", title="Nb. candidats",cex=.7) title(main="Résultats erronés") names(xx) xx dept$dept[sample(1:95,15)] dept xx <- cbind(names=dept$dept[sample(1:95,15),1],n=round(seq(5,300,length=15))) idx <- cut(xx,breaks=c(0,50,100,250),labels=F) xx <- cbind(names=dept[sample(1:95,15),1],n=round(seq(5,300,length=15))) idx <- cut(xx,breaks=c(0,50,100,250),labels=F) xx dept xx <- data.frame(names=dept[sample(1:95,15),1],n=round(seq(5,300,length=15))) xx xx$grp <- cut(xx,breaks=c(0,50,100,250),labels=F) xx$grp <- cut(xx$n,breaks=c(0,50,100,250),labels=F) xx xx$grp <- cut(xx$n,breaks=c(0,50,100,250,1000),labels=F) xx map('france') map('france',regions=xx$names,col=my.cols[xx$grp],add=T) leg.txt <- c("0-50","50-100","100-250","250+") legend("bottomleft",leg.txt,col=my.cols,pch=15,bty="n", title="Nb. candidats",cex=.7) title(main="Résultats erronés") map('france') map('france',regions=xx$names,col=my.cols[xx$grp],add=T) leg.txt <- c("0-50","50-100","100-250","250+") legend("bottomleft",leg.txt,col=my.cols,pch=15,bty="n", title="Nb. candidats",cex=.7) title(main="Résultats erronés") xx$names my.cols[xx$grp] length(xx$names) length(xx$grp) map('france') map('france',regions=xx$names,col=my.cols[xx$grp],fill=T,add=T) leg.txt <- c("0-50","50-100","100-250","250+") legend("bottomleft",leg.txt,col=my.cols,pch=15,bty="n", title="Nb. candidats",cex=.7) title(main="Résultats erronés") png("map_dept_1.png") map('france') map('france',regions=xx$names,col=my.cols[xx$grp],fill=T,add=T) leg.txt <- c("0-50","50-100","100-250","250+") legend("bottomleft",leg.txt,col=my.cols,pch=15,bty="n", title="Nb. candidats",cex=.7) title(main="Résultats erronés") dev.off() leg.txt <- c("0-50","50-100","100-250","250+") map('france') m <- map('france',regions=xx$names,add=T,namesonly=T) m length(m) xx ?write.table write.table(xx,file="dept.txt",sep=",") write.table(xx,file="dept.txt",sep=",",header=F) ?write.table write.table(xx,file="dept.txt",sep=",",quote=F,col.names=F) write.table(xx,file="dept.csv",sep=",",quote=F,row.names=F,col.names=F) write.table(xx,file="dept.csv",sep="\t",quote=F,row.names=F,col.names=F) write.table(xx,file="dept.csv",sep=",",quote=F,row.names=F,col.names=F)