简体   繁体   中英

How to pass an array of histogram breaks to R.hist using RProvider in F#?

I am using RProvider with F# in VS2012. I would like to pass an array of custom histogram breaks (bin edges) to R.hist. Things are ok when I pass an integer number (see line that is commented out). Could you please help me? What is the correct way to handle function overloading in this case?

R documentation on R.hist is here (see "break" arg): https://stat.ethz.ch/R-manual/R-devel/library/graphics/html/hist.html

A working example below:

let arr = [| 12.3; 12.4; 13.3; 12.9; 13.2; 13.6 |]
let breaks = [| 12.0; 12.5; 13.0; 13.5; 14.0 |]
let h_tmp = R.hist(namedParams ["x", box arr;
                                "breaks", box breaks; // <------ fails here!
                                "plot", box true; ])
let h_counts = h_tmp.AsList().["counts"].AsNumeric().GetValue<float[]>()

Many thanks.

What error are you getting?

I tried reproducing this on my machine with the latest RProvider 1.1.15 and it runs without any error and produces the following results, which seems to be correct:

val h_counts : float [] = [|2.0; 1.0; 2.0; 1.0|]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM