Re: [RFC] ob-reticulate: R+Python interface from Babel
Hi Jack, As a frequent reticulate user I am very excited to see this patch. I hope others feel the same and it gets included into org mode as I cannot wait to use it. Best Regards, Kyle On Mon, Aug 24, 2020, 11:28 Jack Kamm wrote: > Hi all, > > Reticulate is an R package for interfacing between R and Python. It allows > accessing objects in a Python session from R and vice versa. See > https://rstudio.github.io/reticulate/ for more info about it. > > I've written a small patch for using reticulate from org-babel. It allows > creating a source block of lang "reticulate", which behaves as Python for > font highlighting and editing, but is executed in an R session via > reticulate. > > I'm wondering whether this should go into org-mode, or whether to package > this separately. I'm also curious whether this would be useful to anyone > here. Any feedback is appreciated. > > The main advantage of reticulate is being able to access Python objects > directly from R and vice versa, without having to write them to a separate > file or pass them through the ":var" header argument. For example, we could > do the following: > > #+begin_src reticulate :session > import pandas as pd > > fib = [0, 1] > for _ in range(10): > fib.append(fib[-1] + fib[-2]) > > df = pd.DataFrame({ > "i": list(range(len(fib))), > "F_i": fib > }) > #+end_src > > #+begin_src R :session :results graphics value file :file fig.png > library(reticulate) > with(py$df, plot(i, F_i)) > #+end_src > > Reticulate source blocks support both "value" and "output" results, and > even supports graphics with matplotlib. It's primarily intended to be used > in sessions, and the ":session" header argument should match between > reticulate and R source blocks. > > Cheers, > Jack > >
Re: [O] orgmode and anova
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. On Thu, Apr 21, 2016, 15:10 Uwe Brauerwrote: > Hello > > Using Kubuntu I just installed R and the following code works nicely > > #+tblname: delsee > | airmass | zenith_seeing | delivered_seeing | > |-+---+--| > | 1.3 | 0.95 |1.1119612 | > | 1.3 | 1.0 |1.1704854 | > | 1.3 | 1.1 |1.2875340 | > | 1.3 | 1.2 |1.4045825 | > #+TBLFM: $3=$2*($1**0.6) > > > #+begin_src R :results output :var delsee=delsee > summary(delsee) > #+end_src > > > Does somebody know whether I could do an ANOVA, comparing these columns > (which does not make much sense, but this is not the point. > > Any help is strongly appreciated. > > thanks > > Uwe Brauer > > >
[O] Bug: sas comments in source blocks confused with headings [8.2.10 (8.2.10-35-g19a7d6-elpaplus @ ~/.emacs.d/elpa/org-plus-contrib-20150406/)]
I included SAS code for reference in an org file and noticed that a SAS comment breaks the folding feature. The buffer is folded only until the comment. The snippet below placed in an org-buffer should clarify what I mean. ** SAS #+BEGIN_SRC sas * a full line comment in SAS code; proc mixed method=reml cl; class D M G; model y = M G M*G; random D D*M D*G/cl alpha=0.05; /* can't do 3-way */ lsmeans M G M*G/cl adjust=tukey; /* only fixed effects */ run; #+END_SRC ** R Here is how to fit the mixed effect model in R. If you press tab on the SAS heading, it doesn't fold all the way to the R heading, but only to the comment line. Perhaps this is fixed in org 8.3? --- Emacs : GNU Emacs 24.4.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.14.7) of 2015-01-17 on bisson Package: Org-mode version 8.2.10 (8.2.10-35-g19a7d6-elpaplus @ /home/k/.emacs.d/elpa/org-plus-contrib-20150406/) current state: == (setq org-drill-optimal-factor-matrix '((1 (2.6 . 4.14))) org-tab-first-hook '(org-hide-block-toggle-maybe org-src-native-tab-command-maybe org-babel-hide-result-toggle-maybe org-babel-header-arg-expand) org-adapt-indentation nil org-speed-command-hook '(org-speed-command-default-hook org-babel-speed-command-hook) org-occur-hook '(org-first-headline-recenter) org-metaup-hook '(org-babel-load-in-session-maybe) org-html-format-drawer-function '(lambda (name contents) contents) org-latex-format-inlinetask-function 'ignore org-confirm-shell-link-function 'yes-or-no-p org-image-actual-width nil org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default org-agenda-inhibit-startup t org-pretty-entities 1 org-latex-format-headline-function 'org-latex-format-headline-default-function org-default-notes-file ~/org/notes.org org-after-todo-state-change-hook '(org-clock-out-if-current) org-latex-format-drawer-function '(lambda (name contents) contents) org-capture-mode-hook '(make-frame) org-from-is-user-regexp nil org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-configure-edit-buffer) org-agenda-before-write-hook '(org-agenda-add-entry-text) org-babel-pre-tangle-hook '(save-buffer) org-font-lock-set-keywords-hook '(org-drill-add-cloze-fontification) org-mode-hook '(#[nil \300\301\302\303\304$\207 [org-add-hook change-major-mode-hook org-show-block-all append local] 5] #[nil \300\301\302\303\304$\207 [org-add-hook change-major-mode-hook org-babel-show-result-all append local] 5] org-babel-result-hide-spec org-babel-hide-all-hashes) org-ascii-format-drawer-function '(lambda (name contents width) contents) org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point org-babel-execute-safely-maybe) org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers org-cycle-hide-inline-tasks org-cycle-show-empty-lines org-optimize-window-after-visibility-change) org-startup-with-latex-preview t org-latex-packages-alist '(( multirow t) ( fontenc t) ( siunitx t) ( xfrac t) ( mathtools t) ( physics t) ( color t)) org-babel-tangle-lang-exts '((maxima . max) (julia . jl) (tcl . tcl) (python . py) (perl . pl) (latex . tex) (emacs-lisp . el)) org-confirm-elisp-link-function 'yes-or-no-p org-startup-with-inline-images t org-metadown-hook '(org-babel-pop-to-session-maybe) org-babel-after-execute-hook '(org-display-inline-images) org-html-format-headline-function 'ignore org-babel-load-languages '((emacs-lisp . t) (calc . t) (sh . t) (latex . t) (R . t) (perl . t) (octave . t) (python . t) (scheme . t) (makefile . t) (tcl . t) (julia . t) (maxima . t)) org-html-format-inlinetask-function 'ignore org-fontify-whole-heading-line t org-clock-out-hook '(org-clock-remove-empty-clock-drawer) org-confirm-babel-evaluate nil org-src-fontify-natively t )
[O] org-spreadsheet: formatting chops off units
Hello everyone, I want to use an org-spreadsheet to perform unit conversions for me. | Mass (g) | Mass (lb) | |--+---| | 300 g| 0.66138679 lb | | 23 kg| 50.706320 lb | | 50 Mg| 110231.13 lb | #+TBLFM: $2=uconvert($1, lb) I made the table above, but can't figure out how to format the output. I tried using the ;%.2f notation shown in the manual, but it cuts the units off for some reason. Here is what org-table displays with ;%.2f appended onto my table formula: | Mass (g) | Mass (lb) | |--+---| | 300 g| 0.66 | | 23 kg| 50.71 | | 50 Mg| 110231.13 | #+TBLFM: $2=uconvert($1, lb);%.2f Here is what I wish appending ;%.2f would cause org-table to display: | Mass (g) | Mass (lb) | |--+---| | 300 g| 0.66 lb | | 23 kg| 50.71 lb | | 50 Mg| 110231.13 lb | #+TBLFM: $2=uconvert($1, lb);%.2f If you type in '0.66138679 lb into calc directly, and press d f 2, calc displays 0.66 lb as desired. Is there any reason for the %.2f notation chops off the units? Is there some better way to accomplish what I want? Thanks! Note: my spreadsheet uses the wrapper function below to convert units with calc. #+begin_src emacs-lisp (defmath uconvert (expression new-units) (math-convert-units expression new-units))) #+end_src -- Kyle C. Andrews kyle.c.andr...@gmail.com
Re: [O] How to integrate org-mode in a MS Windows-/Office-based environment?
Hi Martin, You should be able to link to Excel and Word documents from Org by prefixing the normal path with file+sys: instead of just file. This doesn't work when the files are on a Windows Share (at least for me), though. I'm also interested in getting a robust connection between Org and Outlook so I will be paying attention to this thread with earnest. Best Regards, Kyle On Thu, Jul 12, 2012 at 5:06 PM, M elwood...@web.de wrote: I'm using Emacs org-mode for task and information management in a business environment dominated by Microsoft products (Windows, Office, ...). I wonder how to create a set-up for maximum productivity and I'd like to know how you integrate org-mode in your work on MS Windows. Creating hyperlinks in my org-mode files/tasks, which let me jump directly to E-Mail in MS Outlook (Exchange-based), open Word-, Excel- or Powerpoint documents, etc. is a very helpful feature for integrating org-mode. Are there other techniques, tools or add-ons which are helpful for that purpose? Kind regards Martin
Re: [O] Using org-babel with Scheme
I am having both of these issues on Emacs 24. Emacs crashes sometimes on geiser and babel won't evaluate scheme code as Racket code despite setting 'scheme-program-name and 'org-babel-scheme-cmd to racket. However, Guile will work if both of those variables hold guile. Any new developments? On Wed, Feb 15, 2012 at 9:33 AM, Eric Schulte eric.schu...@gmx.com wrote: Leo Alekseyev dnqu...@gmail.com writes: Is anyone on the list using a recent org-babel with Scheme? I recently started working through SICP, and I'm running into issues evaluating scheme src blocks. Org-babel error buffer pops up with ERROR: Wrong number of arguments to #primitive-generic display, and the minibuffer prompts me for a lisp expression. Is there anything I need to configure beyond (org-babel-do-load-languages 'org-babel-load-languages '((scheme . t)))? (Running latest org from git in Emacs 24; have Chicken scheme and guile installed). I loaded the ob-scheme.el directly (which should be the same as loading it with org-babel-do-load-languages as above) and the following works for me. #+begin_src scheme (+ 1 1 1) #+end_src #+RESULTS: : 3 I have guile installed and I have the `scheme-program-name' variable set to guile elsewhere in my .emacs init. I imagine setting the above variable should enable scheme evaluation. Best, while looking into this I did notice that when launching Geiser (a nice slime-like scheme evaluator) I would sometimes crash my entire Emacs process by pressing C-g when Geiser prompts for a scheme executable. I imagine this is unrelated to your problem, but was certainly surprising. --Leo -- Eric Schulte http://cs.unm.edu/~eschulte/