Actually, the code you uses does recreate/reinitializes the R engine. RProvider does this already I now realise; you do not need to do it in your F# code. The code sample below taken from the R type provider quickstart works fine.
Well, actually this was time I dived into F# and its R provider. Besides, this makes me think R.NET should change its API to prevent new users from falling into this multiple engine initalisations trap.
Well, actually this was time I dived into F# and its R provider. Besides, this makes me think R.NET should change its API to prevent new users from falling into this multiple engine initalisations trap.
#I @"../path/to/RProvider.1.0.6/lib" #r "RDotNet.dll" #r "RDotNet.FSharp.dll" #r "RDotNet.NativeLibrary.dll" #r "RProvider.dll"open System open RDotNet open RProvider open RProvider.``base`` open RProvider.graphics open RProvider.stats // Random number generatorlet rng = Random() let rand () = rng.NextDouble() // Generate fake X1 and X2 let X1s = [ for i in 0 .. 9 -> 10. * rand () ] let X2s = [ for i in 0 .. 9 -> 5. * rand () ] // Build Ys, following the "true" modellet Ys = [ for i in 0 .. 9 -> 5. + 3. * X1s.[i] - 2. * X2s.[i] + rand () ] let dataset = namedParams [ "Y", box Ys; "X1", box X1s; "X2", box X2s; ] |> R.data_frame