- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Formatting is not accepted (col << Format( "Fixed Dec", 10, 2 )) and still getting 3 decimal point as the output. What am I doing wrong?
// Open Data Table: Antibiotic MICs.jmp
// → Data Table( "Antibiotic MICs" )
Open( "$SAMPLE_DATA/Antibiotic MICs.jmp" );
// Standardize column attributes-The main idea is the format= Fixed Dec, 10, 2-show two decimal points
Local( {old dt = Current Data Table()},
Current Data Table( Data Table( "Antibiotic MICs" ) );
For Each( {col, index}, {:streptomycin, :neomycin},
col << Format( "Fixed Dec", 10, 2 )
);
Current Data Table( old dt );
);
rowNum = 3;
colAntib = Column( Data Table( "Antibiotic MICs" ), "neomycin");
//colAntib << Format( "Fixed Dec", 10, 2 );-this also is not working
colAntibVal = colAntib[ rowNum ]; //it is showing 0.007, three decimal points
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Formatting is not accepted (col << Format( "Fixed Dec", 10, 2 )) and still getting 3 decimal point as the output. What am I doing wrong?
Hi Aziza,
I would guess that formatting doesn't change the underlying value but just how the value is diplayed in the data table. Because in the data table it actually shows 0.01 for your example.
If you want to access less decimal places in your code, you probably should round your value.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Formatting is not accepted (col << Format( "Fixed Dec", 10, 2 )) and still getting 3 decimal point as the output. What am I doing wrong?
Hi Anja,
thank you for your input.
I tried this solution. It works more or less. What is now happening is this
round(0.1964565, 2)
/*:
0.2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Formatting is not accepted (col << Format( "Fixed Dec", 10, 2 )) and still getting 3 decimal point as the output. What am I doing wrong?
Even if you change the format in the table the values aren't changed. You could round the value after you get it OR you can use << Get Values with Format
Names Default To Here(1);
dt = Open( "$SAMPLE_DATA/Antibiotic MICs.jmp" );
row_nr = 3;
formatted_values = Column(dt, "neomycin") << Get Values(
Format( "Fixed Dec", 10, 2 ) /* a numeric column will be list of character items if a format is supplied, see format function */
);
row_val = formatted_values[row_nr];
Do note that this will return you with a string not a number (https://www.jmp.com/support/help/en/17.0/#page/jmp/date-and-time-functions.shtml?os=win&source=appli...). You can convert it into a number using Num()