Hot answers tagged

12

UPDATE As of ESS 19.04, the ess-noweb and ess-swv libraries are obsolete: Libraries for literate data analysis are obsolete and not loaded by default. This includes 'ess-noweb', 'ess-swv', and related functionality like 'Rnw-mode'. Users are encouraged to switch to one of several other packages that deal with these modes. For example, ...


8

While doing due research on this, I stumbled upon a small section in the ESS manual: The default value of ess-eval-visibly (t) means that ESS calls block Emacs until they finish. This may be undesirable, especially if commands take long to finish. Users who want input to be displayed and Emacs not to be blocked can set ess-eval-visibly to 'nowait. This ...


7

You need to use the :exports both header argument. By default, org only exports R code, not the results. From the org manual: 14.8.2.8 :exports The :exports header argument is to specify if that part of the Org file is exported to, say, HTML or LaTeX formats. Note that :exports affects only ‘src’ code blocks and not inline code. code The default....


7

Set ess-arg-function-offset to nil: (setf ess-arg-function-offset nil) For me this indents your examples the way that you want them to be. Read the documentation of the variable to find out why (and note that c is a function call). Simply setting it once in an init file does not work. A simple way for it to register is to set it in ess-mode-hook: (add-...


6

I like orgstruct-mode. In the following file you can collapse headings with Tab or S-Tab, much like in org-mode. Note that the eval part below collapsed the file to out-most level when opening the file. ##* sec1 x <- rnorm(10) ##** sec11 y <- x<0 ##* sec 2 z <- x + y ## Local Variables: ## outline-regexp: "##*\\*+\\|\\`" ## orgstruct-heading-...


6

Try this Define t as default header argument with using :var t=10 #+PROPERTY: header-args:R :var t=10 The temperature is src_R{2*t}, and twice of that is src_R{4*t}. Note: Fixed typo in second in-line block and removed t=10; assignment. Exports as The temperature is `20', and twice of that is `40'. Hope that helped! Tested Using emacs version: ...


5

set-default-font by default sets the font for current frame only from the documentation C-hfset-default-fontRET (emphasis mine) (set-default-font FONT &optional KEEP-SIZE FRAMES) This function is obsolete since 23.1; use `set-frame-font' instead. Set the default font to FONT. When called interactively, prompt for the name of a font, and ...


5

Not completly an answer to the question, but when one use R in org-mode's babel: * My example #+name: simple-org-example #+begin_src R :session *my-R* :dir "." :results output graphics :file example.svg :width 18 :height 9 plot(cyl~mpg,data=mtcars) #+end_src Doing a C-c C-c on this in org-mode will create a *my-R* buffer with an interacting ESS buffer, ...


5

There is a function called org-table-transpose-table-at-point which can be used to transpose table at cursor.


5

You're very close! Two changes: For the R code, you'll need a few more headers: #+BEGIN_SRC R :results output graphics :file test.png library("ggplot2") ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, color = Species)) + geom_point() #+END_SRC (Note that the headers change slightly depending on whether you want to use base R, as in your example, ...


5

Add a + to the key to append values to a property. For an instance, in your last example you should write: #+PROPERTY: header-args:R :exports both #+PROPERTY: header-args:R+ :session Note the + behind the key header-args:R in the second line. See the example #+PROPERTY: var foo=1 #+PROPERTY: var+ bar=2 in the orgmode online help http://orgmode.org/...


5

This is an all-in-one solution. It will create and display a PDF from an Rnw. Specifically it will: Save the Rnw buffer and knit it, Apply a given LaTeX engine to the resulting TeX file, Identify the BibTeX engine executable (e.g. biber, bibtex8), Run the BibTeX engine on the TeX file if the bib file is newer than TeX file, Run LaTeX again, 6 Open ...


5

You need to set the :session header argument. This tells org that all R calculations will take place in the same session. For example: #+PROPERTY: header-args:R :session orgR I set my constant here src_R{t=10; 2*t}. Write some more text. And reuse the constant here src_R{t * 4}. On export, this generates:


4

I think the defined constant can be used in tables, and only there. #+CONSTANTS: t=10 | 1 | 10 | | 2 | 20 | #+TBLFM: $2=$1*$t However, you can add the header argument :session to make your second method working: The temperature is src_R[:session]{t=10; 2*t}, and twice of that is src_R[:session]{4*t}. You could also do a (not so pretty) trick. You could ...


4

M-x ess-display-package-index, bound to C-c C-d i by default, does exactly this.


4

See here for a hint to the solution. From the changelist for 12.09-1: ESS[R] Auto-completion: new variable ess-ac-R-argument-suffix to customize the insertion of trailing "=". Defaults to “ = “. And from the documentation for the variable ess-ac-R-argument-suffix: ess-ac-R-argument-suffix is a variable defined in 'ess-r-completion.el'. Its value ...


4

You have to tell org-mode to actually use the listings or listingsutf8 package in your .emacs: (add-to-list 'org-latex-packages-alist '("" "listingsutf8")) Then you'll have a line \usepackage{listings} in the exported TeX file and the pdfLaTeX run will give you the result you want to have. Addition: For minted, I get a satisfying result when using the ...


4

C-c C-s is bound to ess-switch-process. You can also start a new process this way.


3

Here is a try for automating transpose on export, I hope it helps. Example 1: Basic First, We name each of R code blocks by placing #+NAME:. #+NAME: r-out-01 #+begin_src R :results output value c('a','b','c') #+end_src #+RESULTS: r-out-01 | a | | b | | c | #+NAME: r-out-02 #+begin_src R :results output value matrix(1:8, ncol = 4, byrow = TRUE) ##matrix(...


3

Here's a quick and dirty approach. Depending on what you want there's lots of room for improvement. (defun head-at-point () (interactive) (let ((target (thing-at-point 'symbol))) (ess-send-string (ess-get-process ess-local-process-name) (concat "head(" target ")\n"))))


3

As mentioned in my comment, you need to pass the variable as a :var header on the #+begin_src line, not on the #+name: line. But you also need to specify that the results be output to a graphics file. The following worked for me: #+TBLNAME:kuchen | 100 | ABC | | 3 | DEF | | 123 | XYZ | #+name: piechart #+begin_src R :results file graphics :file pie.png :...


2

Another one here, I updated with nadvice.el. 1. Normal Evaluation Now, We have normal evaluation and results here. #+begin_src R :results value c('a','b','c') #+end_src #+RESULTS: | a | | b | | c | 2. Function Override You can override temporary org-babel-R-process-value-result in ob-R.el by C-c C-c the following code. #+BEGIN_SRC emacs-lisp :results ...


2

A standard feature of babel blocks is each block is executed in a new interpreter. Often this is good as changes in one block doesn't mess up others. I have two ideas for you... In this particular case, you could break up the first block in two, so that the first block called the c function and spit out its results in a table that has the name, <...


2

If reading the documentation in your browser instead of directly within Emacs works for you, you can use the html help files instead of the text files by configuring your .Rprofile: Simply replace: ## set the default help type options(help_type = "text") by: ## set the default help type options(help_type = "html") This is what your example help file ...


2

It's no longer required to use Rterm.exe; you can just use R.exe directly. To configure the program name that emacs/ESS uses, set the variable in your .emacs like this: (setq inferior-ess-r-program "R") Alternatively, press C-h v, select the inferior-ess-r-program variable, and use the Customize interface to set and save the setting. If you don't have the ...


2

I believe the reason lies in org-babel-R-write-object-command (defconst org-babel-R-write-object-command "{ function(object,transfer.file) { object invisible( if ( inherits( try( { tfile<-tempfile() write....


2

Note that script-proc-buffer will always be new-buffer since that is an existing buffer when make-comint-in-buffer is called. To bind kill-process to the key sequence q make it somehow interactive and use local-set-key with the wanted buffer current, e.g.: (with-current-buffer script-proc-buffer (local-set-key "q" (lambda () (interactive) (kill-process)))...


1

For other persons who are having the same problem, I just want to answer my own question. I solved this issue by setting copying the shell environment to emacs as, (exec-path-from-shell-copy-env "LC_ALL") (exec-path-from-shell-copy-env "LANG") Thank you, everyone, for your help. I got my answer from https://stat.ethz.ch/pipermail/r-sig-mac/2015-October/...


1

I had the same issue but now it should be fixed in the development version.


1

You can handle this from the R side: * Test this ** Original #+BEGIN_SRC R :session *R-org* :results output raw :exports results library(ascii) df <- data.frame(x=0.110, y=0.132) rownames(df) <- "Rates" print(ascii(df, header=TRUE, colnames=colnames(df), rownames=rownames(df), digits=3, caption="Rates"), type="org") #+...


Only top voted, non community-wiki answers of a minimum length are eligible