plyr

ddplyをPOSIXltを含むデータフレームに適用した場合のエラーについて

ddplyをPOSIXltを含むデータフレームに適用すると以下のようなエラーが出ることがある。 Error in attributes(out) <- attributes(col) : 'names' attribute [9] must be the same length as the vector [1] 対処法としては2つ。 POSIXltをas.characterで文…

水準ごとに回帰をかける

以下を参照。 http://stackoverflow.com/questions/7523427/ddply-with-lm-function 一旦回帰の結果をリストに入れて、coefやらanovaで目的のものを引き出すという感じ。 res <- dlply(iris, .(Species), lm, formula = Sepal.Length~Sepal.Width) coefs <- …