cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
jlmbs
Level III

How to write a script to standardise attributes of columns from a generic data table?

I am trying to write a script which standardises attributes from a generic data table. However, I getting the error "Argument must contain data table in access or evaluation on 'Current Data Table', Current Data Table*###*/(dt_trinean). Does anyone know hoe to fix this error?

giulia_lambiase_0-1666977078601.pnggiulia_lambiase_1-1666977099033.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
vince_faller
Super User (Alumni)

Re: How to write a script to standardise attributes of columns from a generic data table?

the only variable you're giving to the local block is old dt.  Then you're using dt_trinean.  Instead of switching current datatables, it's often better to scope the data table expicitly. 

 

Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");
dt2 = New Table("Example", New Column("Thing", numeric, <<Set Values([1, 2, 3])));
print(current data table()); // DataTable("Example")
foreach({col, index}, 
	{dt:height, Column(dt, "weight"), // I'm telling it to use the dt table instead of dt2 (the current data table)
		dt2:thing // can even switch data tables in the middle no problem.  
	}, 
	col << datatype(Character);
	// then you don't have to change data tables back either
);
Vince Faller - Predictum

View solution in original post

3 REPLIES 3
vince_faller
Super User (Alumni)

Re: How to write a script to standardise attributes of columns from a generic data table?

the only variable you're giving to the local block is old dt.  Then you're using dt_trinean.  Instead of switching current datatables, it's often better to scope the data table expicitly. 

 

Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");
dt2 = New Table("Example", New Column("Thing", numeric, <<Set Values([1, 2, 3])));
print(current data table()); // DataTable("Example")
foreach({col, index}, 
	{dt:height, Column(dt, "weight"), // I'm telling it to use the dt table instead of dt2 (the current data table)
		dt2:thing // can even switch data tables in the middle no problem.  
	}, 
	col << datatype(Character);
	// then you don't have to change data tables back either
);
Vince Faller - Predictum
jlmbs
Level III

Re: How to write a script to standardise attributes of columns from a generic data table?

Thanks, it worked by modifying the script as below:

 

Local( {dt_trinean_lst = Current Data Table()},
	Current Data Table( dt_trinean_lst );
	For Each( {col, index},
		{:"A280 Concentration(mg/ml)"n, :"AvgA280 Concentration (mg/ml)"n,
		:"CVA280 Concentration (%)"n},
		col << Data Type( Numeric ) << Set Modeling Type( "Continuous" ) <<
		Set Field Width( 12 )
	);
	Current Data Table( dt_trinean_lst );
);

Now I want to get the summary of replicates on the concatenated table dt_trinean_lst. The code below throws this error, could you tell why and how to fix it?

giulia_lambiase_0-1667056628855.png

dt_trinean_summary=dt_trinean_lst << Summary(
	Group( :Sample name ),
	Mean( :"A280 Concentration(mg/ml)"n ),
	Mean( :"AvgA280 Concentration (mg/ml)"n ),
	Mean( :"CVA280 Concentration (%)"n ),
	Freq( "None" ),
	Weight( "None" ),
	Link to original data table( 0 )
);

 

vince_faller
Super User (Alumni)

Re: How to write a script to standardise attributes of columns from a generic data table?

because it's a local variable so once you leave the local block. that var doesn't exist anymore.  

 

 

For example.  This will fail after printing.  "inside local = 14"

 

Names default to here(1);
open log();
Local({x=14}, 
	print("inside local = "||char(x))
);
print("outside local = "||char(x));

Vince Faller - Predictum