|
|
@@ -15,8 +15,12 @@ |
|
|
|
#' charger("data.csv") #charger un fichier texte (marche aussi pour les .txt) |
|
|
|
#' charger("donnees.xls") #charger un fichier excel (marche aussi pour les .xlsx) |
|
|
|
#' charger(NULL) |
|
|
|
charger <- function(fichier,nom,feuille=1) |
|
|
|
charger <- function(fichier,nom=NULL,feuille=1) |
|
|
|
{ |
|
|
|
try(detach(.attachd,character.only=T),silent=T) |
|
|
|
if (is.null(nom)) |
|
|
|
nom=strsplit(fichier,"\\.")[[1]][1] |
|
|
|
|
|
|
|
fichier<-paste("../../data/",fichier,sep="") |
|
|
|
if (!file.exists(fichier)) |
|
|
|
{ |
|
|
@@ -28,13 +32,18 @@ charger <- function(fichier,nom,feuille=1) |
|
|
|
else if (grepl("\\.xlsx?$",fichier)) |
|
|
|
x<-read.xlsx(fichier,feuille) |
|
|
|
|
|
|
|
if (file.exists("labels")) |
|
|
|
if (file.exists("labels.txt")) |
|
|
|
{ |
|
|
|
labels=readLines(con=file("labels","r",encoding="ISO-8859-1") |
|
|
|
con=file("labels.txt","r",encoding="ISO-8859-1") |
|
|
|
labels=readLines(con) |
|
|
|
close(con) |
|
|
|
labels=labels[grepl('^ *\\w*? *= *\\".*?\\" *$',labels)] |
|
|
|
labels=paste(labels,collapse=",") |
|
|
|
label_exe = paste("label(x)<-c(",labels,")") |
|
|
|
eval(parse(text=label_exe)) |
|
|
|
} |
|
|
|
|
|
|
|
assign(as.character(substitute(nom)),x,pos=1) |
|
|
|
assign(".attachd",nom,pos=1) |
|
|
|
assign(nom,x,pos=1) |
|
|
|
attach(eval(parse(text=.attachd)),name=.attachd) |
|
|
|
} |