2017-09-23 9 views
1

のRタイププロバイダは、私はF#でCSVを解析しています' と首尾二つのリストを作成する:問題のCsvProvider '

let times = [ for row in airinfo.Rows -> row.Time ]

let passengers = [ for row in airinfo.Rows -> row.AirPassengers ]

timesは小数点リストでありpassengersですintリスト

最終的に私が実行しようとしている。問題は、小数点のリストをプロットしていることを信じて私をリードしている、 R.plot (times, passengers)

R.plot passengers作品しかし手始めに、しかしR.plot timesません。

私は、次の例外を取得:

のSystem.Exception:タイプ Microsoft.FSharp.Collections.FSharpList`1 [[System.Decimalの、mscorlib、 バージョン= 4.0.0.0に登録されませんコンバータ、 マイクロソフトの0:< 57161c90b86b2a10a7450383901c1657>文化= PublicKeyTokenニュートラル= b77a5c561934e089]]または その基本型のいずれか

[email protected]で( メッセージを可能System.String)[0x00001]。 FSh arp.Core.PrintfImpl + StringPrintfEnv 1[TResult].Finalize () [0x00012] in <5893d081904cf4daa745038381d09358>:0   at [email protected][TState,TResidue,TResult,A].Invoke (Microsoft.FSharp.Core.FSharpFunc 2 [T、TResult] ENV、A)[0x00038]で < 5893d081904cf4daa745038381d09358>:0 で[email protected] [T2、TResult、T1]。 RProvider.RInteropInternalで0:> < 57161c90b86b2a10a7450383901c1657に RProvider.RInteropInternal.convertToR [INTYPE(RDotNet.REngineエンジン、 INTYPE値)[0x00061]で0:< 5893d081904cf4daa745038381d09358>の[0x00001] (T2 U)を呼び出します。 REngine.SetValue(RDotNet.REngine this、 System.Object値、Microsoft.FSharp.Core.FSharpOption 1[T] symbolName) [0x00001] in <57161c90b86b2a10a7450383901c1657>:0   at RProvider.RInteropInternal.toR (System.Object value) [0x00019] in <57161c90b86b2a10a7450383901c1657>:0   at [email protected] (System.Collections.Generic.List 1 [T] tempSymbols、System.Object arg)[0x00123] in < 57161c90b86b2a10a7450383901c1657>:0 におけるマイクロソフト:0 [email protected](System.Collections.Generic.IEnumerable 1[System.String]& next) [0x000d8] in <57161c90b86b2a10a7450383901c1657>:0   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase 1 [T] .MoveNextImpl ()[0x00017] 5893d081904cf4daa745038381d09358> <中で。 FSharp.Core.CompilerServices.GeneratedSequenceBase 1[T].System-Collections-IEnumerator-MoveNext () [0x00001] in <5893d081904cf4daa745038381d09358>:0   at System.Collections.Generic.List 1 [T] .. (System.Collections.Generic.IEnumerable 1[T] collection) [0x00077] in <48b95f3df5804531818f80e28ec60191>:0   at Microsoft.FSharp.Collections.SeqModule.ToArray[T] (System.Collections.Generic.IEnumerable 1 [T]源)CTOR [0x0006a] < 5893d081904cf4daa745038381d09358>:0で RProvider.RInterop.callFunc(システム.String packageName、System.String funcName、System.Collections.Generic.IEnumerable`1 [T] argsByName、 System.Object [] varArgs)の[0x0001d]< 57161c90b86b2a10a7450383901c1657>:0 で$ FSI_0012.main @()[0x0002f]で < 511174b5879343f6b1c4aa72a97ef951>:で、0(ラッパー 管理ツーネイティブ)System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod System.Reflection.BindingFlags invokeAttr、System.Reflection.Binder バインダー、System.Object []パラメーター、オブジェクト、オブジェクト[]、System.Exception [システム。< 48b95f3df5804531818f80e28ec60191>でGlobalization.CultureInfo 培養)[0x00032]:0

任意の助けを大幅に高く評価されています。

+0

例外テキストをブロック引用符で再フォーマット –

+0

Rプロバイダはかなり低いレベルで、F#(オプションのような)と.NETタイプについてはわかりません。小数点を浮動小数点数に変換するか、それによって消化できる数値形式に変換してください。おそらく箱に入れる必要があります。呼び出しているコード全体を追加できますか?これは一例として再現することはできません。 – s952163

答えて

0

小数点リストをRProviderが認識する数値型に変換する必要があります。ここで私の作品例です:

#load @"..\packages\RProvider\RProvider.fsx" 

open System 
open RDotNet 
open RProvider 
open RProvider.graphics 

let floatList = [1. ..10.] 
let decList = [1M .. 10M ] 

R.plot(floatList) // this works 
R.plot(decList) // Syystem.exception 

のSystem.Exception:タイプ Microsoft.FSharp.Collections.FSharpList`1 [[System.Decimalの、mscorlib、 バージョン= 4.0.0.0に登録されませんコンバータ、キュルトゥーレニュートラル、PublicKeyToken = = b77a5c561934e089]] またはその基本型のいずれかの

しかし、あなたは別のタイプにあなたのリストを変換することができます:

decList 
|> List.map float 
|> R.plot 

enter image description here

あなたは多分あなたは文字列に変換する必要がありラベルとしてつのリストを使用したい場合、私は上記したようまた、フロート状態にしません。

関連する問題