Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私の問題は、この質問に多少関連しています。
私は以下のようなデータを持っています
V1 V2 .. 1 .. 2 .. 1 .. 3
V1累積的に各値のデータの分散を計算する必要がありますV2(これは、V2たとえば、特定の値に対して、対応するよりも小さい値を持つnすべての行を含める必要があることを意味します。V1V2n
V1
V2
n
ddplyそのような場合に役立ちますか?
ddply
データフレームの重複しないサブセットをddply取得するという概念に基づいて構築されているため、役に立たないと思います。
d <- data.frame(V1=runif(1000),V2=sample(1:10,size=1000,replace=TRUE)) u <- sort(unique(d$V2)) ans <- sapply(u,function(x) { with(d,var(V1[V2<=x])) }) names(ans) <- u
これを行うより効率的な方法があるかどうかはわかりません...