Created
October 10, 2013 19:52
-
-
Save luajalla/6924468 to your computer and use it in GitHub Desktop.
REngine initialization (Mono + OSX, R 2.15 32bit)
- Console app works
- Type provider crashes (added a script file with #r to it)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace rtest | |
open System | |
open RDotNet | |
[<AutoOpen>] | |
module Init = | |
let initR() = | |
let rpath = "/Library/Frameworks/R.framework/Libraries" | |
let rresources = "/Library/Frameworks/R.framework/Resources" | |
let oldpath = Environment.GetEnvironmentVariable "PATH" | |
Environment.SetEnvironmentVariable("PATH", sprintf "%s:%s" rpath oldpath) | |
Environment.SetEnvironmentVariable("R_HOME", rresources) | |
let engine = REngine.CreateInstance("RDotNet") | |
engine.Initialize() | |
let e = engine.Evaluate("1 + 3"); | |
e.AsNumeric() | |
[<EntryPoint>] | |
let main args = | |
initR() |> printfn "%A" //seq [4.0] | |
0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// type provider library | |
namespace rtest | |
open Microsoft.FSharp.Core.CompilerServices | |
open Samples.FSharp.ProvidedTypes | |
[<TypeProvider>] | |
type RProvider(cfg: TypeProviderConfig) as this = | |
inherit TypeProviderForNamespaces() | |
let asm = System.Reflection.Assembly.GetExecutingAssembly() | |
let ns = "REngineRepro" | |
let ty = ProvidedTypeDefinition(asm, ns, "R", Some typeof<obj>) | |
do | |
initR() |> ignore | |
this.AddNamespace(ns, [ty]) | |
[<TypeProviderAssembly>] | |
do () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment