統計解析R たぶんpart3くらい (587レス)
前次1-
抽出解除 必死チェッカー(本家) (べ) 自ID レス栞 あぼーん

393: 2021/06/20(日)18:54 ID:dkTIMvj9(1/4) AAS
前説が長いので最初に結論:
>353は真似しないで欲しい。
[IHaskell](外部リンク:github.comでコードを書く。
``` haskell
import GHC.Exts (groupWith)
分割 = groupWith length
仕事 (a : as) = (length a, length as + 1)
集計 = foldl push mempty where push out a = out ++ pure a
個々 = map
物件 = words "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
省19
394: 2021/06/20(日)18:56 ID:dkTIMvj9(2/4) AAS
例題を次の記事から拝借する。[fmap]{#fmap}
* [Split-Apply-Combine and Map-Reduce in R](外部リンク:burtmonroe.github.io
``` {r fmap, dependson = "self"}
self = with (self, {
分割 = \(x) x |> split (~ cyl);
仕事 = \(x) coef (lm (mpg ~ wt, x));
集計 = \(x) purrr::map_dbl (x, \(x) x ["wt"]);
個々 = \(f) \(x) purrr::map (x, f);
物件 = mtcars;
比較 = \(管, 前処理, 後処理) with (list (`%管%` = 管), {
省18
395: 2021/06/20(日)18:58 ID:dkTIMvj9(3/4) AAS
1つめの"比較"は表を面倒くさい方法で`lm`している。2つめの"比較"は
表の代わりに表のリストを渡している。この場合の"%管%"が前回の投稿の
`%pipe%`に相当する。3つめの"比較"は表の代わりに表への写像を渡している。
このように関手パターンを使うと、引数が様々な"形状"に変化する。

本題に入る。以前、次のようなコードを書いた。[boxplot]{#boxplot}
``` {r, dependson = ""}
none = with (new.env (), {
. = ggplot2::ggplot (mtcars);
. = . + ggplot2::aes (x = factor (cyl), y = wt);
. = . + ggplot2::geom_boxplot ();
省17
396: 2021/06/20(日)19:00 ID:dkTIMvj9(4/4) AAS
次のコードは無限ループする。
``` {r, dependson = ""}
tryCatch ({
a = 1;
a = \(.) . + a;
a (2);
}, error = identity) |> print ();
```
PythonとJSも似たような挙動をするので、現在主流のインタープリターでは
[boxplot](#boxplot)のような横着コードはご法度かもしれない。
省1
前次1-
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル

ぬこの手 ぬこTOP 0.034s