Git Product home page Git Product logo

rprovider's Introduction

F# R Provider

Discord

RProvider

An F# type provider for interoperating with R. For more information, see detailed documentation with tutorials, examples and more. The following tutorials are a good place to start:

The R Provider discovers R packages that are available in your R installation and makes them available as .NET namespaces underneath the parent namespace RProvider. For example, the stats package is available as RProvider.stats. If you open the namespaces you want to use, functions and values will be available as R.name.


Builds

GitHub Actions
Github Actions

NuGet

Package Stable Prerelease
RProvider NuGet Badge NuGet Badge

Requirements

Make sure the following requirements are installed on your system:

  • dotnet SDK 5.0 or greater; and
  • R statistical language. Note: on Windows, there is currently a bug in R preventing us from supporting R versions greater than 4.0.2.
  • R_HOME environment variable set to the R home directory. This can usually be identified by running the command 'R RHOME'.

Note: for .NET framework support, you should use the legacy RProvider 1.2 or earlier; we are no longer supporting these versions.

What does it do?

The R Provider discovers R packages that are available in your R installation and makes them available as .NET namespaces underneath the parent namespace RProvider. For example, the stats package is available as RProvider.stats. If you open the namespaces you want to use, functions and values will be available as R.name. For example, consider this F# interactive script:

#r "nuget:RProvider"

open RProvider
open RProvider.``base``

let v = R.c(1,2,3)

This creates an R numeric vector containing 1,2,3, and names it v. Note that we had to open the base namespace, since the function 'c' is part of that namespace. You should also open namespace RProvider, because it contains some helper functions. As type providers are used by Visual Studio and other IDEs, you will get intellisense for R functions. You will also get compile-time type-checking that the function exists.

Note that you can set the version of RProvider to use (for reproducability) by changing the #r line to:

#r "nuget:RProvider,2.0.3" //replace 2.0.3 with desired version

How to use

RProvider is distributed as a NuGet package, which can be used from an F# script or F# projects. See our documentation for more detailed information and tutorials.

If you are using R 2.15 or later, you should not try to load the RProvider inside a script that is passed to FSI via the --use flag. It seems that something about the way R initializes causes it to hang in that context. Works fine if you load later.

Developing

Install the requirements listed in the above section. To build and test:

  1. Restore dotnet tools: dotnet tool restore
  2. Run FAKE: dotnet fake build -t All

To debug, enable logging by setting the RPROVIDER_LOG environment value to an existing text file.

License

RProvider is covered by the BSD license.

The library uses RDotNet which is also covered by the BSD license.

Maintainers

rprovider's People

Contributors

andrewiom avatar billhally avatar cdrnet avatar dcharbon avatar dsyme avatar evelinag avatar evolvedmicrobe avatar forki avatar geandbe avatar hmansell avatar jiridanek avatar jmp75 avatar jpalmer avatar kmutagene avatar kos59125 avatar mathias-brandewinder avatar nhirschey avatar phdp avatar reedcopsey avatar renkun-ken avatar sergey-tihon avatar tpetricek avatar zyzhu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rprovider's Issues

Using a Proxy with the R Type Provider

I am using the example.fsx file in the RProvider. When I run it from home, it works like a champ. When I run it from work, I get a:

System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
at System.Net.WebClient.DownloadString(Uri address)
at System.Net.WebClient.DownloadString(String address)
at FSI_0002.getStockPrices(String stock, Int32 count) in C:\temp\Open Source R Type Provider 1.0.3\FSharpRProvider-master\src\RProvider\example.fsx:line 24
at <StartupCode$FSI_0002>.$FSI_0002.main@() in C:\temp\Open Source R Type Provider 1.0.3\FSharpRProvider-master\src\RProvider\example.fsx:line 35
Stopped due to error

I checked in Stackoverflow here: http://stackoverflow.com/questions/18981682/f-wsdlservice-type-provider-proxy
I see that type providers are not proxy aware at design time. What about run-time? What do I need to do to get to the service?

Allow NAs to be represented as Option types at the F# boundary

I'm currently passing .NET NaN's to R via RDotNet (without RProvider) then convert them to NA's using a series of RDotNet engine.evaluate statements.

This isn't exactly elegant, so what I'd like to do is streamline the process by taking advantage of RProvider's syntax, e.g.

define a function

    let nan2na (arr: RDotNet.SymbolicExpression) =
        engine.SetSymbol("arr",arr)
        engine.Evaluate("arr[is.nan(arr)] <- NA") |> ignore
        engine.GetSymbol("arr")
    // then we can do the following
    let result = data |> R.data_matrix |> nan2na |> R.fancystuff_etc

However, when I try to do this I get a bunch of nulls back... along with
A first chance exception of type 'System.ArgumentException' occurred in RDotNet.dll

What is the best way of dealing with this?

Mono/linux support

I managed to get this working on linux with mono.

Would you be interested in a pull request with the changes?

Type-safe environment loading

(Just recording an idea that we discussed offline)

You can use save and load in R to export and import environments (e.g. the state of your research). It would be nice if the R provider was able to load the RData files in a type-safe way and gave you access to all the variables defined in the file.

Something like (as a bonus point, the variables could be automatically typed with the appropriate type after conversion to F#):

type m = REnvironment<"MyFile.RData">
m.some
m.another
m.more

See load function.

Suggest some Extension methods to allow fluent-style accessing R objects

RDotNet provides SymbolicExpression object to get access to R objects. Most R objects are constructed as Lists.

For example, a t-test result is a list of statistics and other things, a linear model (lm) is a list of coefficients, residuals and other useful list members. However, it is quite inconvenient to extract the members from a list without chaining several methods and convert the value to appropriate types.

In some packages, the R functions returns S4 object. For example, fUnitRoots package provides a unitrootTest function which returns S4 object that stores much richer information than offered by official R stats packages. But it's a nightmare to extract wanted information from these Lists or the slots of S4 objects. R methods package provide slot() function to extract slots from S4 objects.

As a user of C# and F#, I just want to conveniently get access to the inner information of the R objects without caring too much about the nature of the R object.

Here I developed a very rough RDotNet.Extensions project using F# and RProvider to extend SymbolicExpression:

module RDotNet.Extensions

open RDotNet
open RDotNet.Internals
open RProvider
open RProvider.``base``
open RProvider.methods

type SymbolicExpression with
    /// Get the member symbolic expression of List or S4 object.
    member this.Member (name: string) =
        match this.Type with
        | SymbolicExpressionType.List -> this.AsList().[name]
        | SymbolicExpressionType.S4 -> R.slot(this,name)
        | _ -> invalidOp "Unsupported operation on R object"

    /// Convert the symbolic expression to a typed array.
    member this.ToArray<'a> () = this.Value :?> 'a[]

    /// Get the value from the typed vector by name.
    member this.ValueOf<'a> (name: string) =
        match this.Type with
        | SymbolicExpressionType.NumericVector -> box(this.AsNumeric().[name]) :?> 'a
        | SymbolicExpressionType.CharacterVector -> box(this.AsCharacter().[name]) :?> 'a
        | SymbolicExpressionType.LogicalVector -> box(this.AsLogical().[name]) :?> 'a
        | SymbolicExpressionType.IntegerVector -> box(this.AsInteger().[name]) :?> 'a
        | SymbolicExpressionType.ComplexVector -> box(this.AsComplex().[name]) :?> 'a
        | SymbolicExpressionType.RawVector -> box(this.AsRaw().[name]) :?> 'a
        | _ -> invalidOp "Unsupported operation on R object"

    /// Get the value from the typed vector by index.
    member this.ValueAt<'a> (index: int) = box(this.ToArray<'a>().[index]) :?> 'a

    /// Get the first value from the typed vector.
    member this.First<'a> () = this.ValueAt<'a>(0)

    /// Assign this symbolic expression to a string symbolic identifier in current R environment.
    member this.AssignTo(name:string) = R.assign(name,this) |> ignore

This extension currently allows me to write code in a fluent style like this:

    let dic = dict [("ma",R.c(0.6,0.4,0.1).Value)]
    let list = R.list(dic)
    let data1 = R.arima_sim(model=list,n=500)
    let model = R.arima(x=data1,order=R.c(0,0,5))
    let coef:double[] = model.Member("coef").ToArray()
    let data = R.rnorm(1000)
    let test = R.unitrootTest(data)
    let pvalue:double = test.Member("test").Member("p.value").ValueOf("n") // test is S4 object

I suggest that RDotNet or RProvider adopt some extensions to allow such fluent-style of accessing the data members of R objects.
This issue is raised in RDotNet community, I hope RProvider can also do something about it.

How can I create a valid R function as a Function-type symbolic expression?

I want to try R.sapply functionality which requires me to specify a function that is to apply to a vector, just as I do in R. But I don't know how to construct a R function in a proper way.

In many situations, we may need "apply" functions. I wonder whether I can boost my computation by parallel library, but I'm again stuck by the clusterApply function which also needs a function parameter.

Anybody has an idea?

An attempt to use FSharpRProvider on a box without R installed throws a vague exception

An attempt to reference provider dll produces the following error from fcs:
error FS3053: The type provider 'RProvider.RProvider' reported an error: The type provider constructor has thrown an exception: The type initializer for '<StartupCode$RProvider>.$RInterop' threw an exception.

Although source code specifies the cause as absence of R installed, the correspondent exception when intercepted by fsc gets an inner exception and detailed problem cause message gets buried. To see the real cause of the problem RProvider should be started under debugger, which is detrimental for non-advanced users.

NuGet package does not work with RestorePackages

Automatic package restore in VS or command line apparently does not run the init.ps1 script, so type provider fails to load (at least it looks like that on my laptop). Not sure if there is any possible workaround for this though...

Dont call bindingInfo at runtime

This means we reflect on the function definition at runtime. We should probably generate a quotation at compile time that does the right thing, instead. Performance would be better.

FSharpRProvider- solution has build errors

I downloaded BlueMountainCapital-FSharpRProvider-v0.5-22-g090ddc1 and was trying to build the solution with VS2012.
There are the following compile errors:

  1. Error 1 The type 'CharacterDeviceInterceptor' is not defined C:\FSharpProvider\BlueMountainCapital-FSharpRProvider-090ddc1\RInterop.fs 71 31 RProvider
    let characterDevice = new CharacterDeviceInterceptor()
  2. Error 2 Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved. C:\FSharpProvider\BlueMountainCapital-FSharpRProvider-090ddc1\RInterop.fs 416 13 RProvider
    characterDevice.BeginCapture()

3.Error 3 Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved. C:\FSharpProvider\BlueMountainCapital-FSharpRProvider-090ddc1\RInterop.fs 418 13 RProvider

Could You please help? I am new in F# and with VS 2012

Intensive calling for R functions causes crash

Intensive calling for R functions like lm() is highly probable to cause crash. The code may look like this:

open RProvider
open RProvider.``base``
open RProvider.stats
open RProvider.fUnitRoots

let s =
    [|1..2000|]
    |> Array.map (fun i ->
        let x = R.rnorm(100)
        let y = R.rnorm(100)
        R.assign("x",x) |> ignore
        R.assign("y",y) |> ignore
        let m = R.lm("y~x") // It almost always crashes at this line.
        let res = m.AsList().["residuals"].AsNumeric()
        let test1 = R.adfTest(res)
        let p:double = test1.GetAttribute("test").AsList().["p.value"].AsNumeric().[0]
        p
    )

When the program is running, it almost always crashes for the following exception:

An unhandled exception of type 'System.AccessViolationException' occurred in RDotNet.dll

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

However, when I directly use RDotNet to implement exactly the same thing, no error occurs at all. Actually, I "solved" the problem by adding a GC.Collect() in each iteration, and the probability of error is hugely reduced. I wonder what's the root of the error?

Loading on Mono

I've obtained a 32-bit libR.dylib from the last 32-bit build of R on Mac OSX, 2.15.3. How should I set it up to load RProvider in fsharpi? So far I can open RProvider but not RProvider.base, says namespace 'base' is not defined

A+

2.15 support?

I see from the readme that R 2.15 isn't supported, and that R.Net changes would be required. I also see from the RDotNet page that 2.15 is now supported from that end (http://rdotnet.codeplex.com/). Does this mean 2.15 is now working with this type provider?

REngine.Dispose in AppDomain.DomainUnload fails

I make some unit tests and run them with NUnit Test Adapter 1.0.0.0 on VS 2012. If I run tests with R.NET without RProvider, Dispose method works fine. If I run tests with RProvider, Dispose method stops at R_CleanTempDir.

Any plan for a NuGet package?

Unless I am mistaken, there is no NuGet package for the R TypeProvider. This would make it easier to install - any plans to do that, or reasons why this would be problematic?

Skip convertToR search for values with are SymbolicExpressions

Currently, RInteropInternal.convertToR searches through its various conversion methods even when passed a value which is already a SymbolicExpression (or a subclass of SymbolicExpression). It seems like it might be a useful optimization to check for SymbolicExpressions first, and skip the search if one is found.

A problem using trivial function

Hi all.
I've got a problem I don't understand...

Until a couple of days ago everything (F#-R-Excel Add-Ins) was working fine. Now I get only #value errors in Excel when using R functions.

A trivial example that generates am Excel #value error is attached... Please, note that when I substitute R.pi.GetValue() with a regular float the Excel function works fine.

namespace R_modeling

[]
module linear_model =

open RDotNet
open RProvider
open RProvider.``base``
open RProvider.stats
open ExcelDna.Integration
open System

[<ExcelFunction(Name="r_CpOver", Description="A copy using R", Category="RFunctions")>]
let r_CopyOver([<ExcelArgument(Name="adds Pi in R", Description = "Rpi addition")>] anumber:float ) =

    let pi_plus = R.pi.GetValue<float>() + anumber //2.0 + anumber //works! 
    pi_plus

Any help will be greatly appreciated.
Thanks in advance.

IntelliSense is broken in VS

I see the following error when I try to script using RProvider (VS2012 Update 3).
All required assemblies are located in the same folder with RProvider.dll.

error FS3053: The type provider 'RProvider.RProvider' reported an error: The type provider constructor has thrown an exception: Could not load file or assembly 'RDotNet.NativeLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5f72f6e23c6920d4' or one of its dependencies. The system cannot find the file specified.

The script is following

// Do not work in VS and FSI
//#r @"D:\Research&Development\PRroviderApps\packages\RProvider.1.0.3\lib\RProvider.dll"

// Do not work in VS but work in FSI
#I @"D:\Research&Development\PRroviderApps\packages\RProvider.1.0.3\lib\"
#r "RProvider.dll"

open RProvider

image

NuGet package for RProvider 1.0.5 broken

Just installed the NuGet package and received the same error as #38.

The init.ps1 does not seem to run, and I solved it by manually copying the file into the package directory.

Is this expected behaviour?

Is it possible to access members directly by "." operator or in a cleaner way?

In many cases, I use R objects which is a R List and contains some other objects. If we want to access these elements, we need expr.AsList().["member"].AsNumeric() for example:

open RProvider.tseries
let x = R.rnorm(100)
let test = R.adf_test(x)
let p = test.AsList().["p.value"].AsNumeric().[0]

If we load libraries like fUnitRoots which returns S4 objects, we need to use other ways to extract the member, for example:

open RProvider.fUnitRoots
let x = R.rnorm(100)
let test = R.adfTest(x) // which returns a S4 object rather than a List object.
let p = test.GetAttribute("test").AsList().["p.value"].AsNumeric().[0]

If I define:

type SymbolicExpression with

    /// Get the member symbolic expression of given name.
    member this.Member(name: string) = 
        match this.Type with
        | SymbolicExpressionType.List -> this.AsList().[name]
        | SymbolicExpressionType.S4 -> this.GetAttribute(name)
        | _ -> invalidOp "Unsupported operation on R object"

    /// Get the value from a named vector by name.
    member this.ValueOf<'a>(name: string) = this.AsVector().[name] :?> 'a

    /// Get the value from an indexed vector by index.
    member this.ValueAt<'a>(index: int) = this.AsVector().[index] :?> 'a

    /// Get the first value of a vector.
    member this.First<'a>() = this.ValueAt<'a>(0)

let inline (?) (expr:SymbolicExpression) (mem:string) =
    expr.Member(mem)

This will allow me to write like this:

let x = R.rnorm(100)
let test = R.adf_test(x)
let stat:double = test?statistic.First()
let p:double = test?``p.value``.First()

for another,

let test = R.adfTest(x)
let stat:double = test?test?statistic.First()
let p:double = test?test?``p.value``.First()

which looks much cleaner if such a ? operator is defined.

My question is: Is there a better way to use more RProvider-way to access R object members (which does not bother too much about internal workings and operations of R objects but easy to operate and manipulate) rather than in a R.NET way?

A problem using trivial function

Hi all.
I've got a problem I don't understand...

Until a couple of days ago everything (F#-R-Excel Add-Ins) was working fine. Now I get only #value errors in Excel when using R functions.

A trivial example that generates am Excel #value error follows (sorry, I don't know how to paste code since this is my first post...)... Please, note that when I substitute R.pi.GetValue() with a regular float the Excel function works fine.

Any help will be greatly appreciated. Thanks in advance.

namespace R_modeling

[]
module linear_model =

open RDotNet
open RProvider
open RProvider.``base``
open RProvider.stats
open ExcelDna.Integration
open System

[<ExcelFunction(Name="r_CpOver", Description="A copy using R", Category="RFunctions")>]
let r_CopyOver([<ExcelArgument(Name="adds Pi in R", Description = "Rpi addition")>] anumber:float ) =

    let pi_plus = R.pi.GetValue<float>() + anumber //2.0 + anumber //works! 
    pi_plus

Failed engine initialization because PATH not yet set

I was just using a Debug build of the latest master (with the change made to address issue 29:

9766d24#RProvider.fs

In my build, the code to initialize the engine (in RInterop) was executing before the code (in RProvider) which changes the PATH environment variable. As a consequence, the provider was failing to load during a program execution with a DllNotFound error (i.e. not finding R.dll).

I moved the PATH setting code into a function in RInterop which gets called just before the engine is initialized, and this fixed the problem.

NuGet package for RProvider 1.0.1 broken

When I install the NuGet package, and add references in a FSI file:

r @"..\packages\R.NET.1.5.5\lib\net40\RDotNet.dll"

r @"..\packages\RDotNet.FSharp.0.1.2.1\lib\net40\RDotNet.FSharp.dll"

r @"..\packages\R.NET.1.5.5\lib\net40\RDotNet.NativeLibrary.dll"

r @"..\packages\RProvider.1.0.1\lib\RProvider.dll"

... the last line shows an error:

"The type provider ... reported an error: Assembly Attribute TypeProviderAssemblyAttribute' refers to a designer assembly 'RProvider' which cannot be loaded or doesn't exist. Could not load file or assembly 'RDotNet, Version=1.5.4.0' ..."

ggplot2 does not work

Namespace appears but no functions appear in the Intellisense. If you try to call R.qplot from the IDE, it does not produce anything.

Is there a problem with float arguments

When I execute the following code in the interactive

let d = -0.1700106725339548
let foo = R.pnorm(d, 0.0, 1.0)
let bar = foo.Value

then I get the following result:

val d : float = -0.1700106725
val foo : SymbolicExpression
val bar : obj = [|0.5|]

which is clearly wrong. If I change d to be 1 then the result is correct. What do I do wrong? Is there a problem with float arguments?

using dplyr.R.left__join results in "No Converter registered" message

Executing the code below in fsi results in the following exception:

System.Exception: No converter registered for type Deedle.Frame2[[System.Tuple2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] or any of its base types
at [email protected](String message) in c:\dev\git\RProvider\src\RProvider\RInterop.fs:line 102
at RProvider.RInteropInternal.REngine.SetValue(REngine this, Object value, FSharpOption1 symbolName) in c:\dev\git\RProvider\src\RProvider\RInterop.fs:line 212 at RProvider.RInteropInternal.toR(Object value) in c:\dev\git\RProvider\src\RProvider\RInterop.fs:line 225 at RProvider.RInterop.passArg@312(List1 tempSymbols, Object arg) in c:\dev\git\RProvider\src\RProvider\RInterop.fs:line 326
at [email protected](IEnumerable1& next) in c:\dev\git\RProvider\src\RProvider\RInterop.fs:line 334 at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase1.MoveNextImpl()
at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase1.System-Collections-IEnumerator-MoveNext() at Microsoft.FSharp.Collections.SeqModule.ToArray[T](IEnumerable1 source)
at RProvider.RInterop.callFunc(String packageName, String funcName, IEnumerable`1 argsByName, Object[] varArgs) in c:\dev\git\RProvider\src\RProvider\RInterop.fs:line 331
at RProvider.RInterop.call(String packageName, String funcName, String serializedRVal, Object[] namedArgs, Object[] varArgs) in c:\dev\git\RProvider\src\RProvider\RInterop.fs:line 375
at <StartupCode$FSI_0004>.$FSI_0004.main@() in c:\dev\ModelShift\CleanModel\Script4.fsx:line 25

I @"w:\dev\ModelShift\CleanModel\packages\RProvider.1.0.5"

I @"w:\dev\ModelShift\CleanModel\packages\Deedle.0.9.12"

load "RProvider.fsx"

load "Deedle.fsx"

open RProvider
open RDotNet
open Deedle
open RProvider.dplyr
open System

let periodMembers =[(1,1);(2,1);(3,1);(1,2);(2,2);(3,2);]
let premia =[125;135;169;231;876;24;]
let firstSeries = Series(periodMembers,premia)
let firstFrame = Frame.ofColumns["Premia"=>firstSeries]

let projectedYears = series([1=>2014;2=>2014;3=>2014;])
let projectedMonths = series([1=>"Apr";2=>"May";3=>"Jun"])
let secondFrame = Frame(["year";"month"],[projectedYears;projectedMonths;]) |> Frame.mapRowKeys (fun k -> k,0)

let fullFrame = dplyr.R.left__join (firstFrame, secondFrame, by="NULL")

Namespace 'base' not defined.

This issue may be connected with
[Win x64] R installation & Registry
#28

Code (script1.fsx):

r @"c:\VS\F#\ConsoleApplication1\packages\R.NET.1.5.5\lib\net40\RDotNet.dll"

r @"c:\VS\F#\ConsoleApplication1\packages\RProvider.1.0.5\lib\RProvider.dll"

open RDotNet
open RProvider

open RProvider.base

Error:

The namespace 'base' is not defined.

One more hint:

r-core not installed

reg1

reg2

RProvider is visible in References.

I am using Rx64 3.0.2 only. 32-bit version is not installed.

I have tried adding \bin to path without effect.

Thanks in advance for help.

Using R provider without zoo

If the zoo package is not installed, we should not fail until we actually need it (e.g. when you just use data frames)

Consider not throwing exception when R not installed

It appears that the current behaviour is that the R provider will throw an exception if R is not installed and you reference it using #r "RProvider.dll.

Would it make sense to handle this in some "nicer" way?

(One reason for the question is that if we include R provider in "FsLab", then we'll have a load script that could reference the R provider - even if R is not installed. We could include two load scripts, but it feels that having just one way of loading this would be nicer.)

One possible way would be to generate R type with <summary> saying that R is not installed (or we could generate R.<Note> member similarly to what F# does when you need to add a reference - or used to do earlier (?))

See also fslaborg/zzarchive-FsLab#1

Consider adding FSI pretty printer

The SymbolicExpression object has the Print method that formats the results nicely, so it looks useful to add something like:

fsi.AddPrinter(fun (se:RDotNet.SymbolicExpression) -> 
  se.Type.ToString() + "\n" + se.Print())

I suppose this has some disadvantages - for example, you might not want to always copy the data to F# Interactive.

But I think that having this by default (with the option to turn it off somehow) would make learning/using R provider a lot easier. For example:

> R.sum [ 1 .. 10 ];;
val it : RDotNet.SymbolicExpression = IntegerVector
[1] 55

> R.data_frame(namedParams [ "a", [20 .. 25 ]; "b", [25 .. 30]]);;
val it : RDotNet.SymbolicExpression =
  List
   a  b
1 20 25
2 21 26
3 22 27
4 23 28
5 24 29
6 25 30

Nuget 1.0.3 seems to crash visual studio 2012

Visual Studio crashes and restarts intermittently when running the simple program below.

Additionally the type provider occasionally crashes and intellisense is lost. This is restored only by restarting VS. Exception is non-specific, e.g. "an exception was thrown"

RProvider 1.0.3
R.NET 1.5.5
RDotNet.FSharp 0.1.2.1

R 3.0.2
Win 7 Pro x64

module main

open RProvider
open RProvider.base

let x = R.c(1,2,3)

Reverse R Provider

Would it be feasible to expose F# dlls as R packages? That would complement the R Provider nicely, so you could have full roundtrip, and have people more comfortable with R than F# to be able to start using F#

[Win x64] R installation & Registry

I just want to share experience for people who may struggle figuring out which entry in the registry is actually used to select the R install.

My experience is that R entries in windows registry are quite messy and I spent a bit of time figuring out exactly WHICH entry in the registry is used to find R by the type provider.

In my registry (win64), I can find paths to R install in :

HKEY_LOCAL_MACHINE\Software\R-core\R\InstallPath
HKEY_LOCAL_MACHINE\Software\R-core\R[version]\InstallPath
HKEY_LOCAL_MACHINE\Software\R-core\R64\InstallPath
HKEY_LOCAL_MACHINE\Software\R-core\R64[version]\InstallPath
HKEY_LOCAL_MACHINE\Software\Wow6432Node\R-core\R\InstallPath
HKEY_LOCAL_MACHINE\Software\Wow6432Node\R-core\R[version]\InstallPath
HKEY_LOCAL_MACHINE\Software\Wow6432Node\R-core\R32\InstallPath
HKEY_LOCAL_MACHINE\Software\Wow6432Node\R-core\R32[version]\InstallPath

In Visual Studio and for x86 process, the key actually used, on my machine, is
HKEY_LOCAL_MACHINE\Software\Wow6432Node\R-core\R\InstallPath

For a x64 process, it is :
HKEY_LOCAL_MACHINE\Software\R-core\R64\InstallPath

The InstallPath under [version] does not seem be used.

Hope this may help someone.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.