Closed pnavaro closed 4 years ago
Salut Gregory
Si j'exécute le code example de la fonction compare_lists
library(OTrecod) > list1 = list(A = 1:4, B = as.factor(c("A","B","C")), C = matrix(1:6,ncol = 3)) > list2 = list(A = 1:4, B = as.factor(c("A","B")), C = matrix(1:6,ncol = 3)) > list3 = list(A = 1:4, B = as.factor(c("A","B","C")),C = matrix(c(1:5,7),ncol = 3)) > list4 = list(A = 1:4, B = as.factor(c("A","B","C")), C = matrix(1:6,ncol = 2)) > list5 = list(A = 1:4, B = as.factor(c("A","B")), C = matrix(1:6,ncol = 2)) > list6 = list(A = 1:4, B = as.factor(c("A","B")), C = data1) > list7 = list(A = 1:4, B = as.factor(c("A","B")), C = data2) > compare_lists(list1,list2) [1] FALSE TRUE FALSE > compare_lists(list1,list3) [1] FALSE FALSE TRUE > compare_lists(list1,list4) Error in listA[[i]] != listB[[i]] : tableaux de tailles inadéquates > compare_lists(list1,list5) Error in listA[[i]] != listB[[i]] : tableaux de tailles inadéquates > compare_lists(list6,list7) [1] FALSE FALSE TRUE >
Si j'ai bien compris la description, on pourrait remplacer par
> compare_lists <- function( listA, listB) return(as.vector(!mapply(identical, listA, listB))) > compare_lists(list1,list2) [1] FALSE TRUE FALSE > compare_lists(list1,list3) [1] FALSE FALSE TRUE > compare_lists(list1,list4) [1] FALSE FALSE TRUE > compare_lists(list1,list5) [1] FALSE TRUE TRUE > compare_lists(list6,list7) [1] FALSE FALSE TRUE
Salut Gregory
Si j'exécute le code example de la fonction compare_lists
Si j'ai bien compris la description, on pourrait remplacer par