Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
marktaylor
Level II

New Column Question

Data Table( "Data" ) << Summary(
	Group( :Row, :Col ),
	Range( :Data Trace ),
	New Column("ABC",formula(:Range(Data Trace)*1E15)),
	Freq( "None" ),
	Weight( "None" )
);

I'm trying to create a new column as shown above whereby i multiple the column in the line above it by 1E15. The table is created but the new column "ABC" doesn't show up. Maybe there's something wrong with my syntax. Any ideas most welcome. Thanks, Mark

2 REPLIES 2
Highlighted
David_Burnham
Super User

Re: New Column Question

You are sending the summary message to a table.  Everything in parentheses is an argument to the summary message e.g. group, range.

 

You can't just add new column - this is not a valid parameter for the summary message. It is however, a message that you can send to a table.  So create the summary table first then sent the new column message to that:

dtSumm = DataTable("data") << Summary( . . . );
dtSumm << NewColumn( . . .);
-Dave
Highlighted
marktaylor
Level II

Re: New Column Question

Hi David, Thanks for your reply. As a complete beginner, I'm just not that familiar with the syntax. I've copied the entire script below. It allows you to pick a number of files, create a table for each then concatenate the data into a single table then create a summary table and from that a heatmap graph. In the summary table "Range" is the color by variable in the heatmap. However, I'd like to multiply the values by 1E15 and also be able to put a title on the graph. I'm just not sure how to do this but it feels like it should only take a line or two or to add *1E15 in front of something. It's frustrating as what I want to do is so easy but not being a programmer seems very hard (I guess I just struggle with the language/syntax)

 

names = Pick File(
	"Select Data File",
	"$DESKTOP",
	{"Text Files|txt;csv", "All Files|*"},
	1,
	0,
	"Data",
	multiple
);


nitems = N Items(names);


path = substr(names[1],2,Contains(names[1],"/",-1)-1);


For(i=1, i <= nitems, i++, names[i] = substr(words(names[i],"/"),7));


names = Files In Directory(path);

Data = New Table("Data", Character, Nominal);
col = New Column( "DC Bias Volt", Numeric, "Continuous", Format( "Best", 12 ) );
col = New Column( "Data Trace", Numeric, "Continuous", Format( "Best", 12 ) );
col = New Column( "File" );
col = New Column( "Row" );
col = New Column( "Col" );


For(i=1, i <= nitems, i++, 

dt = Open(Concat(path, names[i]),
	
	columns(
		New Column( "DC Bias Volt", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "Data Trace", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "Memory Trace", Numeric, "Continuous", Format( "Best", 12 ) )
			),
	Import Settings(
		End Of Line( CRLF, CR, LF ),
		End Of Field( Tab, CSV( 0 ) ),
		Strip Quotes( 1 ),
		Use Apostrophe as Quotation Mark( 0 ),
		Use Regional Settings( 0 ),
		Scan Whole File( 1 ),
		Treat empty columns as numeric( 0 ),
		CompressNumericColumns( 0 ),
		CompressCharacterColumns( 0 ),
		CompressAllowListCheck( 0 ),
		Labels( 1 ),
		Column Names Start( 6 ),
		Data Starts( 7 ),
		Lines To Read( 101 ),
		Year Rule( "20xx" )
		
	)
	);
	Metadata = Words(names[i], "_");
	Die_Row = Substr( Metadata[6], 2, 2 );
	Die_Col = Substr( Metadata[6], 5, 2 );
	dt << New Column( "File", Numeric, Nominal );
	dt << New Column( "Row", Character, Nominal );
	dt << New Column( "Col", Character, Nominal );
	:File << Set Each Value( i );
	:Row << Set Each Value( Die_Row );
	:Col << Set Each Value( Die_Col );
	If(Metadata[1] == "CSV",
	Data << Concatenate( dt, "Append to First Table" ));
	Close(dt,NoSave);
	
);

Data Table( "Data" ) << Summary(
	Group( :Row, :Col ),
	Range( :Data Trace ),
	Freq( "None" ),
	Weight( "None" )
);


Graph Builder(
	Size( 1112, 704 ),
	Variables( X( :Col ), Y( :Col ), Color( :Name( "Range(Data Trace)" ) ) ),
	Elements( Heatmap( X, Y, Legend( 5 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Col",
			ScaleBox,
			{Min( 0 ), Max( 60 ), Inc( 1 ), Minor Ticks( 0 )}
		),
		Dispatch(
			{},
			"Col",
			ScaleBox( 2 ),
			{Min( 0 ), Max( 60 ), Inc( 1 ), Minor Ticks( 0 )}
		)
	)
);
Article Labels