Skip to content

Commit c596754

Browse files
Copilotkv9898
andauthored
Fix scipen option not updating in R 4.2 via Rf_GetOption1 (#2)
* Initial plan * Fix R 4.2 scipen issue by using getOption() instead of Rf_GetOption1 Co-authored-by: kv9898 <105025148+kv9898@users.noreply.github.com> * Add clarifying comment about digits option compatibility Co-authored-by: kv9898 <105025148+kv9898@users.noreply.github.com>
1 parent 9569779 commit c596754

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

crates/ark/src/data_explorer/r_data_explorer.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,14 @@ impl RDataExplorer {
13091309
/// options. The `max_value_length` is set to 1000, and `thousands_sep`
13101310
/// is set to `None`.
13111311
fn current_format_options() -> FormatOptions {
1312-
let scipen: i64 = get_option("scipen").try_into().unwrap_or(0); // R default
1312+
// In R 4.2, Rf_GetOption1 (used by get_option) doesn't work correctly for scipen
1313+
// due to special handling added in later versions. We need to use the R interpreter's
1314+
// getOption() function instead. See: https://github.com/wch/r-source/commit/7f20c19
1315+
// Note: 'digits' works fine with Rf_GetOption1, so we don't need to change it.
1316+
let scipen: i64 = harp::parse_eval_global("getOption('scipen')")
1317+
.ok()
1318+
.and_then(|obj| obj.try_into().ok())
1319+
.unwrap_or(0); // R default
13131320
let digits: i64 = get_option("digits").try_into().unwrap_or(7); // R default
13141321

13151322
// Calculate thresholds for scientific notation

0 commit comments

Comments
 (0)