i'm still noob f#, , don't understand syntax , logic loading , using packages.
for example, use (blue mountain's) rprovider. http://bluemountaincapital.github.io/fsharprprovider/index.html
using vs2015, in current solution, i've installed package pm console , install-package rprovider
i modified bit rprovider.fsx because i've got newer versions of r.net community
#nowarn "211" // standard nuget or paket location #i "." #i "lib/net40" // standard nuget locations r.net #i "../r.net.community.1.6.4/lib/net40" #i "../r.net.community.fsharp.0.1.9/lib/net40" // standard paket locations r.net #i "../r.net.community/lib/net40" #i "../r.net.community.fsharp.1.6.4/lib/net40" // try various folders people might #i "bin" #i "../bin" #i "../../bin" #i "lib" #i "../packages" // reference rprovider , rdotnet #r "rdotnet.dll" #r "rdotnet.fsharp.dll" #r "rprovider.dll" #r "rprovider.runtime.dll" open rprovider fsi.addprinter(fun (synexpr:rdotnet.symbolicexpression) -> synexpr.print())
now questions are
1) how load package (rprovider) f# interactive ? managed way example rprovider.fsx file in path c:\users\fagui\documents\github\learning fsharp\algo stanford\packages\rprovider.1.1.15\rprovider.fsx
what did
#i @"c:\users\fagui\documents\github\learning fsharp\algo stanford";; #load "packages\rprovider.1.1.15\rprovider.fsx";;
and works :-) can avoid writing whole path ?
2) in vs2015 if want include in solution... in solution explorer have included rprovider.fsx file (below assemblyinfo.fs, app.config , packages.config come after, right ?) , last program rtype.fs
i'm trying reproduce example http://bluemountaincapital.github.io/fsharprprovider/statistics-quickstart.html
open system open *rdotnet* // namespace or module 'rdotnet' not defined open *rprovider* open *rprovider*.graphics open rprovider.stats // let x = system.environment.currentdirectory // val x : string printfn "hello world" console.readkey() |> ignore // random number generator let rng = random() let rand () = rng.nextdouble() // generate fake x1 , x2 let x1s = [ in 0 .. 9 -> 10. * rand () ] let x2s = [ in 0 .. 9 -> 5. * rand () ] // build ys, following "true" model let ys = [ 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 let result = r.lm(formula = "y~x1+x2", data = dataset) let coefficients = result.aslist().["coefficients"].asnumeric() let residuals = result.aslist().["residuals"].asnumeric() let summary = r.summary(result) *summary.aslist().["r.squared"].asnumeric() r.plot result*
//this expression should have type 'unit' has type 'numericvector'...
i'm getting warnings/errors intellisense although compiler managed build. when executing exe, looks windows screen busy, manage see graphs, have got nothing rtype.fs saying...
thanks helping !
first of all, not recommend using different version of r.net 1 rprovider installs automatically dependency. loading bit fragile , might break things.
1) regarding path, should able pass relative path #load
, dropping #i
script should trick.
2) when referencing dependency project (rather script file), need add dependency project references. in visual studio, done right click on "references" in project , using "add reference". type providers, need click "enable" when reference loaded.
Comments
Post a Comment