-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathfslab.fsx
70 lines (56 loc) · 1.73 KB
/
fslab.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
(**
---
category: Documentation
categoryindex: 1
index: 6
---
*)
(*** condition: prepare ***)
#nowarn "211"
#r "../src/RProvider/bin/Release/net7.0/RDotNet.dll"
#r "../src/RProvider/bin/Release/net7.0/RProvider.Runtime.dll"
#r "../src/RProvider/bin/Release/net7.0/RProvider.DesignTime.dll"
#r "../src/RProvider/bin/Release/net7.0/RProvider.dll"
(*** condition: fsx ***)
#if FSX
#r "nuget: RProvider,{{package-version}}"
#endif // FSX
(*** condition: ipynb ***)
#if IPYNB
#r "nuget: RProvider,{{package-version}}"
#endif // IPYNB
(**
Working with the FsLab ecosystem
===============================
The R type provider is interoperable with other packages in
FsLab through its plugin architecture. Some examples are shown
below. If you would like to see better interoperability between
R and other FsLab packages, submit an issue to their repository
for the creation of an RProvider plugin.
### Deedle - data frame manipulation
Deedle provides types for F# data frame and time series manipulation.
To use with RProvider, first install the Deedle.RPlugin package from
nuget; once this is installed, you do not need to reference it in your
script files.
*)
#r "nuget:Deedle.RPlugin"
(**
In a new F# script file, first open Deedle and RProvider:
[lang=fsharp]
#r "nuget:RProvider"
*)
#r "nuget:Deedle"
open RProvider
open RProvider.``base``
open RProvider.datasets
open Deedle
(**
The Deedle R plugin should be loaded by the R type provider automatically.
You can now convert back and forth between R data frames and Deedle frames
by using type annotations:
*)
let mtcars : Frame<string, string> = R.mtcars.GetValue()
// Pass Deedle data to R and print the R output
R.as_data_frame(mtcars)
// Pass Deedle data to R and get column means
R.colMeans(mtcars)