From mboxrd@z Thu Jan 1 00:00:00 1970 From: Uwe Brauer Subject: Re: orgmode and anova Date: Fri, 22 Apr 2016 08:07:22 +0000 Message-ID: <877ffqt6bp.fsf@mat.ucm.es> References: <87shye6ao3.fsf@mat.ucm.es> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atW7m-0002xN-5W for emacs-orgmode@gnu.org; Fri, 22 Apr 2016 04:07:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1atW7i-0000gO-T2 for emacs-orgmode@gnu.org; Fri, 22 Apr 2016 04:07:38 -0400 Received: from plane.gmane.org ([80.91.229.3]:55555) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atW7i-0000gH-MX for emacs-orgmode@gnu.org; Fri, 22 Apr 2016 04:07:34 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1atW7f-0007wR-Hz for emacs-orgmode@gnu.org; Fri, 22 Apr 2016 10:07:31 +0200 Received: from gilgamesch.quim.ucm.es ([147.96.12.99]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 22 Apr 2016 10:07:31 +0200 Received: from oub by gilgamesch.quim.ucm.es with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 22 Apr 2016 10:07:31 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org >>> "Kyle" == Kyle Andrews writes: > If you wanted to fit a linear regression model with R, you could do > so with the lm function. Calling anova on the output of the > regression would give you a regression anova table. > model <- lm(delivered_seeing ~ zeenith_seeing, data = delsee) > anova(model) > You would need non-zero residuals for that to be useful of course. > Otherwise, you need to stack your *_seeing columns into one column > with another column saying which kind of seeing it was and then: > model.aov <- aov(seeing ~ factor(kind), data = delsee2) > You could do the stacking in a number of ways. My favorite is to use > the gather function in the tidyr package. > aov is just a wrapper around lm, so just take the same approach as > before to get the ANOVA table. Hope that helps. Yes to a certain extend. I was able to perform an anova just comparing the means of three samples. I did this in the following way: First the data in table form #+tblname: myanova | C1 | C2 | C3 | |------+----+----| | 19 | 20 | 16 | | 22 | 21 | 15 | | 20 | 33 | 18 | | 18 | 27 | 26 | | 25 | 40 | 17 | Then the following command did precisely what I wanted #+begin_src R :results output org wrap :exports results a = c(19,22,20,18,25) b = c(20,21,33,27,40) c = c(16,15,18,26,17) dati = c(a, b, c) groups = factor(rep(letters[1:3], each = 5)) fit = lm(formula = dati ~ groups) anova(fit) #+end_src I actually do not really understand precisely the meaning of groups = factor(rep(letters[1:3], each = 5)) but I also do not care much Now executing the code, resulted in #+RESULTS: #+BEGIN_SRC org Analysis of Variance Table Response: dati Df Sum Sq Mean Sq F value Pr(>F) groups 2 260.93 130.467 4.0061 0.04648 * Residuals 12 390.80 32.567 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #+END_SRC The only thing I was interested in was the F and the p valor. However now comes the question. I don't want to write the data in vector form as in a = c(19,22,20,18,25) I want to extract them from the table: #+tblname: myanova | C1 1 | C2 | C3 | | 19 | 20 | 16 | | 22 | 21 | 15 | | 20 | 33 | 18 | | 18 | 27 | 26 | | 25 | 40 | 17 | (Rationale: I have a huge table with 300 entries and I don't want to transform each colum in question into a vector) So this is more a orgmode than a R question: is there a way to extract from a given table its columns and perform via R an anova?? (I could ask the same for matlab, for which I have to transform the table into a matlab matrix, which again I want to avoid.) By hope is there is a sort of generalisation of my first example: #+tblname: myan1 | growth | sugar | |--------+-------| | 75 | 45 | | 72 | 44 | | 73 | 89 | | 61 | 40 | | 67 | 23 | | 64 | 33 | | 62 | 22 | | 63 | 22 | #+begin_src R :results output :var myan1=myan1 summary(myan1) #+end_src The command summary directly extracts the information from that table. I hope that something similar is possible for the anova. thanks Uwe Brauer