JMP 17.2 > RAPPORT PERSONNALISÉ > BOÎTE DE COLONNES DE CHAÎNE > Comment distribuer une longue liste en plusieurs colonnes ?Bonjour la communauté JMP,
J'expérimente un rapport personnalisé (voir ci-dessous) pour lequel je souhaite répartir des listes de longueur variable en plusieurs colonnes dans une chaîne de caractères (String Col Box()). Par exemple, pour la liste affichée dans le script, je souhaite répartir ses éléments en quatre colonnes de 17 lignes.
Le script simplifié (j'ai supprimé tout sauf les lignes essentielles) :
Names Default to Here (1);
datastring = { "ASPM", "AURKA", "AURKB", "BIRC5", "BUB1", "BUB1B", "CCNB1", "CCNB2", "CCNE2", "CDC20", "CDC6", "CDCA2", "CDCA5", "CDCA8", "CDK1", "CDT1",
"CENPE", "CENPF", "CENPK", "CENPN", "CENPS", "CENPW", "DIAPH3", "DLGAP5", "ECT2", "ESCO2", "FAM83D", "HJURP", "KIF11", "KIF14", "KIF15", "KIF18A",
"KIF18B", "KIF23", "KIF2C", "KIF4A", "KIFC1", "KNL1", "MAD2L1", "MKI67", "NCAPG", "NCAPH", "NDC80", "NEK2", "NUF2", "NUSAP1", "OIP5", "PLK1", "PRC1", "PSRC1",
"PTTG1", "RACGAP1", "SGO1", "SGO2", "SKA1", "SKA3", "SPAG5", "SPC24", "SPC25", "TACC3", "TOP2A", "TPX2", "TRIP13", "TTK", "UBE2C", "UHRF1", "ZWILCH", "ZWINT"};
// The length of the list varies from 4 to 125 items, depending on the specific report
rep_w = New Window ("REPORT TEST",
mainframe = HList Box("DATA",
text_data = TableBox (Col Span Box ("MEMBERS", String Col Box ("Genes", datastring)))
)
);
Merci.
Cordialement,
TS
Automatisation et scriptsPartage et communication des résultatsWindowsRé: JMP 17.2 > RAPPORT PERSONNALISÉ > BOÎTE DE COLONNES DE CHAÎNE > Comment distribuer une longue liste en plusieurs colonnes ?Voici une façon de faire ce que vous voulez. J'ai décomposé le code en instructions individuelles codées en dur, en supposant que vous souhaitiez intégrer une logique de boucle au code final.

theList=rep_w[stringcolbox(1)]<
<GET></GET>
Ré: JMP 17.2 > RAPPORT PERSONNALISÉ > BOÎTE DE COLONNES DE CHAÎNE > Comment distribuer une longue liste en plusieurs colonnes ?Salut txnelson,
Merci pour votre retour, mais ceci fournit une solution pour analyser les entrées d'une boîte de colonnes de type String dans une table. Je cherche actuellement autre chose : comment analyser une liste en plusieurs colonnes au sein d'une structure de colonnes de type String ?
Meilleur,
TS
Ré: JMP 17.2 > RAPPORT PERSONNALISÉ > BOÎTE DE COLONNES DE CHAÎNE > Comment distribuer une longue liste en plusieurs colonnes ?Est-ce ce que tu veux ?

Names Default to Here (1);
datastring = { "ASPM", "AURKA", "AURKB", "BIRC5", "BUB1", "BUB1B", "CCNB1", "CCNB2", "CCNE2", "CDC20", "CDC6", "CDCA2", "CDCA5", "CDCA8", "CDK1", "CDT1",
"CENPE", "CENPF", "CENPK", "CENPN", "CENPS", "CENPW", "DIAPH3", "DLGAP5", "ECT2", "ESCO2", "FAM83D", "HJURP", "KIF11", "KIF14", "KIF15", "KIF18A",
"KIF18B", "KIF23", "KIF2C", "KIF4A", "KIFC1", "KNL1", "MAD2L1", "MKI67", "NCAPG", "NCAPH", "NDC80", "NEK2", "NUF2", "NUSAP1", "OIP5", "PLK1", "PRC1", "PSRC1",
"PTTG1", "RACGAP1", "SGO1", "SGO2", "SKA1", "SKA3", "SPAG5", "SPC24", "SPC25", "TACC3", "TOP2A", "TPX2", "TRIP13", "TTK", "UBE2C", "UHRF1", "ZWILCH", "ZWINT"};
// The length of the list varies from 4 to 125 items, depending on the specific report
rep_w = New Window ("REPORT TEST",
mainframe = HList Box("DATA",
text_data = TableBox (Col Span Box ("MEMBERS"))
)
);
text_data<
<APPEND></APPEND>
Ré: JMP 17.2 > RAPPORT PERSONNALISÉ > BOÎTE DE COLONNES DE CHAÎNE > Comment distribuer une longue liste en plusieurs colonnes ?@Thierry_S
Voici une méthode généralisée pour le faire en JSL. J'ai créé une fonction qui nécessite une liste originale et un entier. Cette fonction divise la liste originale en n listes plus petites et renvoie la liste des listes. Si le nombre d'éléments de la liste originale n'est pas divisible par n, la n-ième colonne contiendra le reste des éléments. Cela permet de conserver la généralité de la fonction au cas où vous souhaiteriez la réutiliser pour un tableau comportant plus ou moins de colonnes.
Le tableau est ensuite créé en ajoutant chaque liste sous forme de chaîne col box à une boîte de tableau :
Names Default to Here (1);
splitList_fxn = function( {list, n},
// split a list into into n evenly divided lists and return a list of lists
// if list items/n is not an integer, place the extra items in the nth column
{i,j,k,n,lists,thisList,listSize,items},
lists = {};
items = n items( list );
listSize = round( items/n );
k = 0; // counter
for( i = 1, i <= n, i++,
thisList = {};
if( i != n,
// all but the last list
for( j = (k*listSize)+1, j <= listSize*i, j++,
insert into( thisList, list[j] )
),
// last list will be the remaining items in case there is a remainder
for( j = (k*listSize)+1, j <= items, j++,
insert into( thisList, list[j] )
)
);
k++;
insert into( lists, eval list( list( thisList ) ) )
);
return( lists )
);
// number of columns
n = 4;
// original list
datastring = { "ASPM", "AURKA", "AURKB", "BIRC5", "BUB1", "BUB1B", "CCNB1", "CCNB2", "CCNE2", "CDC20", "CDC6", "CDCA2", "CDCA5", "CDCA8", "CDK1", "CDT1",
"CENPE", "CENPF", "CENPK", "CENPN", "CENPS", "CENPW", "DIAPH3", "DLGAP5", "ECT2", "ESCO2", "FAM83D", "HJURP", "KIF11", "KIF14", "KIF15", "KIF18A",
"KIF18B", "KIF23", "KIF2C", "KIF4A", "KIFC1", "KNL1", "MAD2L1", "MKI67", "NCAPG", "NCAPH", "NDC80", "NEK2", "NUF2", "NUSAP1", "OIP5", "PLK1", "PRC1", "PSRC1",
"PTTG1", "RACGAP1", "SGO1", "SGO2", "SKA1", "SKA3", "SPAG5", "SPC24", "SPC25", "TACC3", "TOP2A", "TPX2", "TRIP13", "TTK", "UBE2C", "UHRF1", "ZWILCH", "ZWINT"};
// The length of the list varies from 4 to 125 items, depending on the specific report
// split the original list into n lists of equal size
col_lists = splitList_fxn( datastring, n );
// create table box and append string col boxes with each list
table = tablebox();
for each( {list,index}, col_lists,
table << append( string col box( "Col " || char(index), list ) )
);
// create report window
rep_w = new window( "REPORT TEST",
mainframe = HList Box("DATA",
table
)
);
n = 4

n = 8

Ré: JMP 17.2 > RAPPORT PERSONNALISÉ > BOÎTE DE COLONNES DE CHAÎNE > Comment distribuer une longue liste en plusieurs colonnes ?splitList_fxn = function( {list, n},
{default local},
lists = {};
Nparts =ceiling(nitems(list)/n);
i=0;
while(nitems(list),
i++;
chunk = remove from (list, 1,Nparts);
Insert Into(lists, eval list({chunk}));
);
if(i
<N></N>
<P><BR /><CODE class=" language-jsl">Insert Into(lists, eval list({chunk})); ?
It's need till:
Insérer dans : Aplatir (0|1)