Come inserire più dati senza il nome della colonna?Di seguito è riportato JSL per creare una tabella JMP.
dt = Nuova tabella( "Esempio piano",
Nuova colonna ("ID unità", Carattere, Nominale ),
Nuova colonna( "Dati1", Numerico, Continuo, Formato( "Migliore", 12 ) ),
Nuova colonna( "Dati2", Numerico, Continuo, Formato( "Migliore", 12 ) ),
Nuova colonna( "Dati3", Numerico, Continuo, Formato( "Migliore", 12 ) ),
);
dtdata={
{ID unità = "A", Dati1 = 1.1, Dati2 = 2.1, Dati3 = 3.1},
{ID unità = "B", Dati1 = 1.2, Dati2 = 2.2, Dati3 = 3.2},
{ID unità = "C", Dati1 = 1.3, Dati2 = 2.3, Dati3 = 3.3}
};
dt << Aggiungi righe ( dtdata );
Vorrei inserire più dati senza definire il nome della colonna come segue.
dtdata={
{"A", 1.1, 2.1, 3.1},
{"B", 1.2, 2.2, 3.2},
{"C", 1.3, 2.3, 3.3}
};
Sopra non è la risposta giusta. Per favore fatemi sapere la sintassi JSL corretta.
Ri: Come inserire più dati senza il nome della colonna?Questa situazione è trattata nella documentazione. Vedere Aiuto > Libri > Guida allo scripting. C'è una sezione sui diversi modi per aggiungere righe alla tabella dati. Ci sono molti esempi in tutta la guida. Ecco l'estratto:
Aggiungi righe
Per aggiungere righe, invia un messaggio Aggiungi righe e specifica quante righe. Puoi anche specificare dopo di che riga inserire le nuove righe. Gli argomenti possono essere numeri o espressioni che valutano i numeri.
dt << Add Rows( 3 ); // add 3 rows to bottom of data table
dt << Add Rows( 3, 10 ); /* add 3 rows after the 10th row, moving the 11th and lower rows farther down */
Una variante di Aggiungi righe consente di specificare un argomento che produce un elenco di assegnazioni.
Le assegnazioni possono essere separate con virgole o punti e virgola.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Add Rows(
{:name = "Peter", :age = 14, :sex = "M", :height = 61, :weight = 124}
);
O
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Add Rows(
{:name = "Peter"; :age = 14; :sex = "M"; :height = 61; :weight = 124}
);
Puoi inviare diversi argomenti che producono elenchi o anche un elenco di elenchi. Il seguente copione
crea una tabella di dati con i comandi Aggiungi righe di ogni varietà:
dt = New Table( "Cities" );
dt << New Column( "xx", Numeric );
dt << New Column( "cc", Character, width( 12 ) );
dt << Add Rows( {xx = 12, cc = "Chicago"} ); // single list
dt << Add Rows( {xx = 13, cc = "New York"}, {xx = 14, cc = "Newark"} );
// several lists
dt << Add Rows(
{{xx = 15, cc = "San Francisco"}, {xx = Sqrt( 256 ), cc = "Oakland"}}
); // list of lists
a = {xx = 20, cc = "Miami"};
dt << Add Rows( a ); // evaluate as single list
b={{xx = 17, cc = "San Antonio"},{xx = 18, cc = "Houston"}, {xx = 19, cc =
"Dallas"}};
dt << Add Rows( b ); // evaluate as list of lists
Ri: Come inserire più dati senza il nome della colonna?Ecco un paio di opzioni che funzionano con JMP 13 e versioni successive.
dt = New Table( "Floor Example",
New Column( "Unit ID", Character, Nominal ),
New Column( "Data1", Numeric, Continuous, Format( "Best", 12 ) ),
New Column( "Data2", Numeric, Continuous, Format( "Best", 12 ) ),
New Column( "Data3", Numeric, Continuous, Format( "Best", 12 ) ),
);
dt << add rows(nitems(dtdata));
dtdata={
{"A", 1.1, 2.1, 3.1},
{"B", 1.2, 2.2, 3.2},
{"C", 1.3, 2.3, 3.3}
};
For Each Row(dt, dt[row(),1::ncol(dt)]=dtdata[row()]);
//or create a function to append
addrows = function({listofrows, ctbl=current data table()}, {nr,nc, i},
nr = nrow(ctbl);
nc = ncol(ctbl);
for(i=1, i <= nitems(listofrows), i++,
ctbl << add rows(1);
ctbl[nr+i, 1::nc] = listofrows[i]
);
); //end function
//add the rows again to demo this function
addrows(dtdata);