Skip to content

Commit

Permalink
Merge pull request #14 from dougy147/master
Browse files Browse the repository at this point in the history
Merge 'dico' environment with latest update
  • Loading branch information
NicolasStefaniak committed Jun 26, 2024
2 parents 3690a30 + 4337359 commit a15028f
Show file tree
Hide file tree
Showing 50 changed files with 4,186 additions and 4,148 deletions.
32 changes: 16 additions & 16 deletions R/Centrer.red.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ Centrer.red <-
packages<-c('svDialogs')
#faire l analyse par groupe # regler le probleme des noms
list()->Resultats
X<-txt_other_data
while(any(X==txt_other_data)){nom <- Filter( function(x) 'data.frame' %in% class( get(x) ), ls(envir=.GlobalEnv) )
if(info==TRUE) {print((ask_chose_database))}
nom<-dlgList(c(nom,txt_other_data) , multiple = FALSE, title=txt_dataframe_choice)$res
X<-.dico[["txt_other_data"]]
while(any(X==.dico[["txt_other_data"]])){nom <- Filter( function(x) 'data.frame' %in% class( get(x) ), ls(envir=.GlobalEnv) )
if(info==TRUE) {print((.dico[["ask_chose_database"]]))}
nom<-dlgList(c(nom,.dico[["txt_other_data"]]) , multiple = FALSE, title=.dico[["txt_dataframe_choice"]])$res
if(length(nom)==0) return(preprocess())
data<-get(nom)
if(info==TRUE) {print((ask_chose_variables))}
X<-dlgList(names(data), multiple = TRUE, title=txt_variables)$res
if(info==TRUE) {print((.dico[["ask_chose_variables"]]))}
X<-dlgList(names(data), multiple = TRUE, title=.dico[["txt_variables"]])$res
if(length(X)==0) X<-donnees()
if(any(sapply(data[,X], class) %in% c("integer", "numeric")==FALSE)) {print(desc_at_least_one_non_numeric)
X<-txt_other_data
if(any(sapply(data[,X], class) %in% c("integer", "numeric")==FALSE)) {print(.dico[["desc_at_least_one_non_numeric"]])
X<-.dico[["txt_other_data"]]
str(data)}
}


if(info==TRUE) {writeLines(desc_center_and_center_reduce_explaination)}
dlgList(c(txt_center, txt_center_reduce, txt_inferior_proba, txt_superior_proba), preselect=txt_center_reduce, multiple = TRUE, title=ask_what_to_do)$res->choix
if(info==TRUE) {writeLines(.dico[["desc_center_and_center_reduce_explaination"]])}
dlgList(c(.dico[["txt_center"]], .dico[["txt_center_reduce"]], .dico[["txt_inferior_proba"]], .dico[["txt_superior_proba"]]), preselect=.dico[["txt_center_reduce"]], multiple = TRUE, title=.dico[["ask_what_to_do"]])$res->choix
if(length(choix)==0) return(preprocess())

for(i in 1:length(choix)){
if(choix[i]==txt_center) {S<-FALSE
nn<-txt_center}else {S<-TRUE
nn<-txt_centered_dot_reduced}
if(choix[i]==.dico[["txt_center"]]) {S<-FALSE
nn<-.dico[["txt_center"]]}else {S<-TRUE
nn<-.dico[["txt_centered_dot_reduced"]]}
scale(data[,X], scale=S)->centree
matrix(centree, ncol=length(X))->centree
if(choix[i]==txt_superior_proba|choix[i]==txt_inferior_proba){
if(choix[i]==txt_superior_proba){
if(choix[i]==.dico[["txt_superior_proba"]]|choix[i]==.dico[["txt_inferior_proba"]]){
if(choix[i]==.dico[["txt_superior_proba"]]){
nn<-"p.sup"
lower<-FALSE
}else {
Expand All @@ -44,6 +44,6 @@ Centrer.red <-

assign(nom, data, envir=.GlobalEnv)
View(data)
Resultats<-paste(desc_succesful_operation)
Resultats<-paste(.dico[["desc_succesful_operation"]])
return(Resultats)
}
16 changes: 8 additions & 8 deletions R/SelectionV.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ SelectionV <-
list()->Resultats
choix.data()->data
if(length(data)==0) return(preprocess())
if(info==TRUE) print(ask_variables)
X<-dlgList(c(paste(names(data), "(format :", sapply(data, class), ")", sep=" "), txt_other_data), multiple = TRUE,
title=txt_variable)$res
if(info==TRUE) print(.dico[["ask_variables"]])
X<-dlgList(c(paste(names(data), "(format :", sapply(data, class), ")", sep=" "), .dico[["txt_other_data"]]), multiple = TRUE,
title=.dico[["txt_variable"]])$res
if(length(X)==0) return(preprocess())
if( X== txt_other_data) return(SelectionV())
if( X== .dico[["txt_other_data"]]) return(SelectionV())
listes<-data.frame(paste(names(data), "(format :", sapply(data, class), ")", sep=" "), 1:length(data))
subset(listes, listes[,1] %in% X)[,2]->X
data[,X]->data
fichier<- dlgInput(ask_filename, txt_selection)$res
if(length(fichier)==0) fichier<-txt_selection
fichier<- dlgInput(.dico[["ask_filename"]], .dico[["txt_selection"]])$res
if(length(fichier)==0) fichier<-.dico[["txt_selection"]]
strsplit(fichier, ":")->fichier
tail(fichier[[1]],n=1)->fichier
assign(x=fichier, value=data, envir=.GlobalEnv)
View(data, txt_selected_data)
Resultats<-paste(desc_variables_are_in, fichier)
View(data, .dico[["txt_selected_data"]])
Resultats<-paste(.dico[["desc_variables_are_in"]], fichier)
return(Resultats)
}
24 changes: 12 additions & 12 deletions R/VI.multiples.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ VI.multiples <-
nvar<-length(data)
try(psych::outlier(data, bad=T, na.rm=T,plot=T),silent=T)->essai
if(class(essai)=='try-error'){
msgBox(desc_singular_matrix_mahalanobis_on_max_info)
msgBox(.dico[["desc_singular_matrix_mahalanobis_on_max_info"]])
data->data2
rankifremoved <- sapply(1:ncol(data2), function (x) qr(data2[,-x])$rank)
which(rankifremoved == max(rankifremoved))->rangs
Expand All @@ -23,13 +23,13 @@ VI.multiples <-
if(class(essai)=='try-error') {
corr.test(data2)$r->matrice
if(any(abs(matrice)==1)) {
msgBox(desc_perfectly_correlated_variables_in_matrix_trying_to_solve)
msgBox(.dico[["desc_perfectly_correlated_variables_in_matrix_trying_to_solve"]])
which(abs(matrice)==1, arr.ind=TRUE)->un
un<-un[-which(un[,1]==un[,2]),]
data2[,-un[,2]]->data2
try(psych::outlier(data2), silent=T)->essai
if(class(essai)=='try-error') {
writeLines(desc_cannot_compute_mahalanobis)
writeLines(.dico[["desc_cannot_compute_mahalanobis"]])
0->data$D.Mahalanobis }
}else{essai-> data$D.Mahalanobis}
} else{ essai-> data$D.Mahalanobis
Expand All @@ -42,30 +42,30 @@ VI.multiples <-
data[which(data$D.Mahalanobis>seuil),]->outliers
length(outliers[,1])/length(data[,1])*100->pourcent

msgBox(paste(round(pourcent,2), desc_percentage_outliers))
msgBox(paste(round(pourcent,2), .dico[["desc_percentage_outliers"]]))


if(pourcent!=0){
writeLines(desc_outliers_removal_implications)
writeLines(.dico[["desc_outliers_removal_implications"]])

suppr<- dlgList(c(txt_suppress_all_outliers, txt_suppress_outliers_manually),
preselect=c(txt_suppress_all_outliers), multiple = FALSE, title=ask_how_to_remove)$res
suppr<- dlgList(c(.dico[["txt_suppress_all_outliers"]], .dico[["txt_suppress_outliers_manually"]]),
preselect=c(.dico[["txt_suppress_all_outliers"]]), multiple = FALSE, title=.dico[["ask_how_to_remove"]])$res
if(length(suppr)==0) return(NULL)
if(suppr==txt_suppress_all_outliers) {data[which(data$D.Mahalanobis<seuil),]->data
outliers->Resultats[[txt_labeled_outliers]]}else{
if(suppr==.dico[["txt_suppress_all_outliers"]]) {data[which(data$D.Mahalanobis<seuil),]->data
outliers->Resultats[[.dico[["txt_labeled_outliers"]]]]}else{
suppression<-"yes"
outliers<-data.frame()
while(suppression=="yes"){
print(data[which.max(data$D.Mahalanobis),])
cat (ask_press_enter_to_continue)
cat (.dico[["ask_press_enter_to_continue"]])
line <- readline()
dlgMessage(ask_suppress_this_obs, "yesno")$res->suppression
dlgMessage(.dico[["ask_suppress_this_obs"]], "yesno")$res->suppression
if(suppression=="yes") {rbind(outliers, data[which.max(data$D.Mahalanobis),])->outliers
data[-which.max(data$D.Mahalanobis),]->data

}
}
Resultats[[txt_labeled_outliers]]<-outliers
Resultats[[.dico[["txt_labeled_outliers"]]]]<-outliers
}
}
Resultats$data<-data
Expand Down
36 changes: 18 additions & 18 deletions R/analyse.R
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
analyse <-
function(html=T){options (warn=-1)
require(svDialogs)
dlgList(c(txt_descriptive_statistics,txt_chi_squared,txt_correlations,
txt_student_t, txt_anova_ancova,
txt_regressions,
txt_analysis_factor_component,
txt_fiability_analysis), preselect=NULL, multiple = FALSE, title=ask_analysis_type)$res->choix
dlgList(c(.dico[["txt_descriptive_statistics"]],.dico[["txt_chi_squared"]],.dico[["txt_correlations"]],
.dico[["txt_student_t"]], .dico[["txt_anova_ancova"]],
.dico[["txt_regressions"]],
.dico[["txt_analysis_factor_component"]],
.dico[["txt_fiability_analysis"]]), preselect=NULL, multiple = FALSE, title=.dico[["ask_analysis_type"]])$res->choix
if(length(choix)==0) return(easieR())
if(choix==txt_chi_squared) chi(html=html)->Resultats
if(choix==txt_student_t) test.t(html=html)->Resultats
if(choix==txt_anova_ancova) {
if(choix==.dico[["txt_chi_squared"]]) chi(html=html)->Resultats
if(choix==.dico[["txt_student_t"]]) test.t(html=html)->Resultats
if(choix==.dico[["txt_anova_ancova"]]) {
Filter( function(x) 'aovplus' %in% class( get(x) ), ls(envir=.GlobalEnv))->nom1
if(length(nom1)==0) {
ez.anova(html=html)->Resultats
} else {
html=html
dlgList(c(txt_principal_analysis,
txt_complementary_results),
dlgList(c(.dico[["txt_principal_analysis"]],
.dico[["txt_complementary_results"]]),
preselect=NULL,
multiple = FALSE,
title=ask_analysis_type)$res->choix
if(choix==txt_principal_analysis) {
title=.dico[["ask_analysis_type"]])$res->choix
if(choix==.dico[["txt_principal_analysis"]]) {
ez.anova(html=html)->Resultats
} else {
aov.plus(html=html)->Resultats
}
}
}
if(choix==txt_correlations) choix.corr(html=html)->Resultats
if(choix==txt_regressions) choix.reg(html=html)->Resultats
#if(choix==txt_logistic_regressions) regressions.log()->Resultats
if(choix==txt_analysis_factor_component) factor.an(html=html)->Resultats
if(choix==txt_fiability_analysis) fiabilite(html=html)->Resultats
if(choix==txt_descriptive_statistics) stat.desc(html=html)->Resultats
if(choix==.dico[["txt_correlations"]]) choix.corr(html=html)->Resultats
if(choix==.dico[["txt_regressions"]]) choix.reg(html=html)->Resultats
#if(choix==.dico[["txt_logistic_regressions"]]) regressions.log()->Resultats
if(choix==.dico[["txt_analysis_factor_component"]]) factor.an(html=html)->Resultats
if(choix==.dico[["txt_fiability_analysis"]]) fiabilite(html=html)->Resultats
if(choix==.dico[["txt_descriptive_statistics"]]) stat.desc(html=html)->Resultats
return(Resultats)
}
48 changes: 24 additions & 24 deletions R/aov.plus.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ aov.plus <-
if(is.null(aov.plus.list)){
Filter( function(x) 'aovplus' %in% class( get(x) ), ls(envir=.GlobalEnv))->nom1
if(length(nom1)==0) {
writeLines(desc_no_compatible_object_in_mem_for_aov)
writeLines(.dico[["desc_no_compatible_object_in_mem_for_aov"]])
return(ez.anova())}
if(length(nom1)==1) aov.plus.list<-get(nom1) else{
if(info=='TRUE') writeLines(ask_wanted_model)
nom1 <- dlgList(nom1, multiple = FALSE, title=ask_model)$res
if(info=='TRUE') writeLines(.dico[["ask_wanted_model"]])
nom1 <- dlgList(nom1, multiple = FALSE, title=.dico[["ask_model"]])$res
if(length(nom1)==0) {nom1<-NULL
aov.plus.list<-NULL}
if(!is.null(nom1)) aov.plus.list<-get(nom1)
Expand All @@ -23,60 +23,60 @@ aov.plus <-


if(length(aov.plus.list)==3){
writeLines(ask_complete_or_outliers)
type<-dlgList(names(aov.plus.list)[2:3], multiple = FALSE, title=ask_which_data_to_analyse)$res
if(length(type)==0) return(desc_user_exited_aov_plus)
if(type==txt_complete_dataset) aov.plus.list[[2]]->aov.plus.list else aov.plus.list[[2]]->aov.plus.list
writeLines(.dico[["ask_complete_or_outliers"]])
type<-dlgList(names(aov.plus.list)[2:3], multiple = FALSE, title=.dico[["ask_which_data_to_analyse"]])$res
if(length(type)==0) return(.dico[["desc_user_exited_aov_plus"]])
if(type==.dico[["txt_complete_dataset"]]) aov.plus.list[[2]]->aov.plus.list else aov.plus.list[[2]]->aov.plus.list
}else aov.plus.list[[2]]->aov.plus.list


writeLines(desc_this_function_means_and_sd_adjusted_interaction_effect_possible)
choix<-dlgList(c(txt_means_adjusted_standard_errors,txt_contrasts),
multiple = TRUE, title=ask_which_data_to_analyse)$res
writeLines(.dico[["desc_this_function_means_and_sd_adjusted_interaction_effect_possible"]])
choix<-dlgList(c(.dico[["txt_means_adjusted_standard_errors"]],.dico[["txt_contrasts"]]),
multiple = TRUE, title=.dico[["ask_which_data_to_analyse"]])$res
if(length(choix)==0) return(analyse())

Resultats<-list()
noms<-names(summary(aov.plus.list[["em.out"]]))[which(sapply(summary(aov.plus.list[["em.out"]]),class) =="factor")]

if(any(choix==txt_means_adjusted_standard_errors)){
writeLines(ask_which_factors_combination_for_adjust_means)
facteurs<-dlgList(noms, multiple = TRUE, title=ask_what_to_print)$res
if(any(choix==.dico[["txt_means_adjusted_standard_errors"]])){
writeLines(.dico[["ask_which_factors_combination_for_adjust_means"]])
facteurs<-dlgList(noms, multiple = TRUE, title=.dico[["ask_what_to_print"]])$res
if(length(facteurs)==0) return(aov.plus())
formula<-paste0('~',facteurs[[1]])
if(length(facteurs)>1){
for(i in 2:length(facteurs)){
formula<-paste(formula, '+', facteurs[i])
}}
recordPlot()->graphe
Resultats[[txt_adjusted_means_graph]]<-emmip(object= aov.plus.in[[txt_complete_dataset]]$em.out,as.formula(formula) , CIs=T)
em.out<-emmeans(object= aov.plus.in[[txt_complete_dataset]]$em.out,as.formula(formula), CIs=T)
Resultats[[txt_adjusted_means]]<-data.frame(em.out)
Resultats[[.dico[["txt_adjusted_means_graph"]]]]<-emmip(object= aov.plus.in[[.dico[["txt_complete_dataset"]]]]$em.out,as.formula(formula) , CIs=T)
em.out<-emmeans(object= aov.plus.in[[.dico[["txt_complete_dataset"]]]]$em.out,as.formula(formula), CIs=T)
Resultats[[.dico[["txt_adjusted_means"]]]]<-data.frame(em.out)

}

if(any(choix==txt_contrasts)){
writeLines(ask_specify_contrasts)
if(any(choix==.dico[["txt_contrasts"]])){
writeLines(.dico[["ask_specify_contrasts"]])
if(length(choix)==0) return(aov.plus())
p.adjust<-dlgList(c("holm", "hochberg", "hommel", "bonferroni", "fdr","tukey","scheffe",
"sidak","dunnettx","mvt" ,"none" ), preselect="holm", multiple = FALSE, title=ask_correction_type)$res
"sidak","dunnettx","mvt" ,"none" ), preselect="holm", multiple = FALSE, title=.dico[["ask_correction_type"]])$res
if(length(p.adjust)==0) p.adjust<-"none"

cont.data<-data.frame(aov.plus.in[[txt_complete_dataset]]$em.out)
cont.data<-data.frame(aov.plus.in[[.dico[["txt_complete_dataset"]]]]$em.out)
cont.data<-cont.data[, noms]
cont.data<-fix(cont.data)
suppress<-which(colSums(is.na(cont.data)) > 0)
if(length(suppress>0)) cont.data<-cont.data[,-suppress]
Resultats$Contrates$coefficients<-cont.data
emm.out<-contrast(aov.plus.in[[txt_complete_dataset]]$em.out,
emm.out<-contrast(aov.plus.in[[.dico[["txt_complete_dataset"]]]]$em.out,
method= list(cont.data[, which(sapply(cont.data, class)=="numeric")]), adjust=p.adjust)
emm.out<-data.frame(emm.out)
names(emm.out)[6]<-txt_p_dot_val # TODO translation
names(emm.out)[6]<-.dico[["txt_p_dot_val"]] # TODO translation

emm.out$contrast<-names(cont.data)[which(sapply(cont.data, class)=="numeric")]
Resultats$Contrates$contrastes<-emm.out
}
ref1(packages)->Resultats[[desc_references]]
.add.result(Resultats=Resultats, name =paste(txt_anova_plus, Sys.time() ))
ref1(packages)->Resultats[[.dico[["desc_references"]]]]
.add.result(Resultats=Resultats, name =paste(.dico[["txt_anova_plus"]], Sys.time() ))
# if(sauvegarde==T) save(Resultats=Resultats ,choix ="Resultats.aov.plus", env=.e)
if(html) ez.html(Resultats)
return(Resultats)
Expand Down
Loading

0 comments on commit a15028f

Please sign in to comment.