fslaborg / RProvider

Access R packages from F#
http://fslab.org/RProvider/
Other
235 stars 69 forks source link

Error in base::sin(0, 1) : 2 arguments passed to 'sin' which requires 1 #186

Closed FaguiCurtain closed 1 year ago

FaguiCurtain commented 7 years ago

running RProvider1.1.20 on a Terminal window on MacOS

I try to run the example from http://bluemountaincapital.github.io/FSharpRProvider/mac-and-linux.html

R.mean([1;2;3;4)] R.x11() R.sin(1)

> R.sin(1.0);;

val it : RDotNet.SymbolicExpression = [1] 0.841471

all work fine

However >R.sin(1.0);; Error in base::sin(0, 1) : 2 arguments passed to 'sin' which requires 1

RDotNet.EvaluationException: Error in base::sin(0, 1) : 2 arguments passed to 'sin' which requires 1

at RDotNet.REngine.Parse (System.String statement, System.Text.StringBuilder incompleteStatement) [0x000a0] in :0 at RDotNet.REngine+d__0.MoveNext () [0x0008f] in :0 at System.Linq.Enumerable.LastOrDefault[TSource] (System.Collections.Generic.IEnumerable1[T] source) [0x00042] in <2392cff65f724abaaed9de072f62bc4a>:0 at RDotNet.REngine.Evaluate (System.String statement) [0x0000d] in <bc069eb3146d4bcda8475794f512037f>:0 at RProvider.RInteropInternal+eval@292.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00026] in <57161c90b86b2a10a7450383901c1657>:0 at RProvider.Internal.Logging.logWithOutput[a] (RProvider.CharacterDeviceInterceptor characterDevice, Microsoft.FSharp.Core.FSharpFunc2[T,TResult] f) [0x0007e] in <57161c90b86b2a10a7450383901c1657>:0 at RProvider.RInteropInternal.eval (System.String expr) [0x0000c] in <57161c90b86b2a10a7450383901c1657>:0 at <StartupCode$FSI_0028>.$FSI_0028.main@ () [0x00046] in <23b88108285f4035b1dcf54f78a47062>:0 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in :0 Stopped due to error

I first wondered if it had to do with regional settings (comma or dot separator for numbers) but the example with 0.1 and 1.0 suggest otherwise

AndrewIOM commented 2 years ago

I'm not able to reproduce this bug using the latest RProvider with .NET 5 running dotnet fsi, macOS 11, R 4.1.1.

> let x1 : float = R.sin(1).GetValue()
- let x2 : float = R.sin(1.0).GetValue();;
val x1 : float = 0.8414709848
val x2 : float = 0.8414709848

Screenshot 2021-09-22 at 11 10 57

noklesta commented 2 years ago

I am getting the same error as the OP. In my locale (Norwegian), comma is used as the decimal separator, which perhaps supports the OP's suggestion that the issue lies there somehow.

Like in the OP's case, R.sin (1.0) works fine, but I suppose that might be because the decimal is ignored in that case?

.NET 6, macOS 11 (Apple Silicon), R 4.1.2, RProvider 2.0.2.

Skjermbilde 2021-11-29 kl  10 35 40
noklesta commented 2 years ago

The workaround I found was to set LC_ALL to e.g. "C" or "en_US.UTF-8" before starting dotnet fsi or VSCode, which confirms that the problem is related to locale.

By the way, I have to change LCALL - setting any of the other LC* variables individually does not work.

AndrewIOM commented 1 year ago

This issue should be fixed in the new release 2.1.0. Please re-open if it re-occurs.