Skip to content

Commit

Permalink
Use InvariantCulture when formating R commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter-B- committed Jun 19, 2019
1 parent 2b54034 commit ea6c55c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Optimization/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Globalization;
using RDotNet;
using System.Linq;

Expand Down Expand Up @@ -50,7 +51,7 @@ static void TestOptimCsharp(REngine engine)
{
x = -1 + rand.NextDouble() * (3 - (-1));
y = -1 + rand.NextDouble() * (3 - (-1));
r = engine.Evaluate(string.Format("rosen({0}, {1})", x, y)).AsNumeric().ToArray()[0];
r = engine.Evaluate(string.Format(CultureInfo.InvariantCulture, "rosen({0}, {1})", x, y)).AsNumeric().ToArray()[0];
if (r < rb)
{
rb = r;
Expand Down
4 changes: 3 additions & 1 deletion SourceRCode/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ static void Main(string[] args)
/*
// if testing for http://stackoverflow.com/questions/32236596/calling-user-defined-functions-inside-a-script-in-r-net
double value1 = 1, value2 = 2;
var dataframe = engine.Evaluate(string.Format("dataframe <- userDefinedFunctionOne(parameter1 = {0}, parameter2 = {1})",
var dataframe = engine.Evaluate(string.Format(
CultureInfo.InvariantCulture,
"dataframe <- userDefinedFunctionOne(parameter1 = {0}, parameter2 = {1})",
value1,
value2)).AsDataFrame();
// with
Expand Down

0 comments on commit ea6c55c

Please sign in to comment.