Subscribe Bookmark RSS Feed

How to get entire row values using JSL?

ram

Contributor

Joined:

Jun 5, 2017

HI All,

how we can get intire row values using jsl for a given row?

3 REPLIES
ian_jmp

Staff

Joined:

Jun 23, 2011

If you only have numeric columns, you could exploit 'GetAsMatrix'. If you have character and numeric columns, you could use 'GetAllColumnsAsMatrix', but then you still have to handle the coded character values. So, in the latter case, it might be simpler to just define a function:

NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

getRow =
Function({tbl, rn}, {DefaultLocal},
	rowContents = {};
	for(c=1, c<=NCols(dt), c++,
		InsertInto(rowContents, Column(tbl, c)[rn]);
	);
	rowContents;
);

Print(getRow(dt, 5));

 

Craige_Hales

Staff

Joined:

Mar 21, 2013

In JMP 13 you can use data table subscripting

dt = Open( "$sample_data/big class.jmp" );
row5 = dt[5, 0];
Show( row5 );

row5 = {"LILLIE", 12, "F", 52, 64};

Craige
ian_jmp

Staff

Joined:

Jun 23, 2011

Nice!

Note how data table subscripting gives either a list or matrix, as needed:

NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << colorByColumn(:sex);
r4Vals = dt[4,0];
Print(r4Vals);
dt << deleteColumns({:name, :sex});
r4Vals = dt[4,0];
Print(r4Vals);
rsc = dt << NewColumn("Row States", Row State);
rsc << copyFromRowStates;
r4Vals = dt[4,0];
Print(r4Vals);
dt << NewColumn("Expression", Expression);
r4Vals = dt[4,0];
Print(r4Vals);