Skip to content

Commit

Permalink
remove outdated Sweave material
Browse files Browse the repository at this point in the history
  • Loading branch information
kjhealy committed Oct 12, 2014
1 parent 171c51c commit 28b1b17
Showing 1 changed file with 2 additions and 65 deletions.
67 changes: 2 additions & 65 deletions starter-kit-stats.org
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This file provides settings for ESS and R.
* R and ESS
Load ESS: Emacs Speaks Statistics, and several further tweaks for
R.

** Load ESS
#+src-name: ess-mode
#+begin_src emacs-lisp
Expand All @@ -23,7 +23,7 @@ This file provides settings for ESS and R.

** Define Rnw-mode and make LaTeX aware of it.
#+srcname: misc-r
#+begin_src emacs-lisp
#+begin_src emacs-lisp :tangle no
(add-to-list 'auto-mode-alist '("\\.Rnw\\'" . Rnw-mode))
(add-to-list 'auto-mode-alist '("\\.Snw\\'" . Rnw-mode))
(add-to-list 'auto-mode-alist '("\\.Rmd\\'" . Rnw-mode))
Expand Down Expand Up @@ -98,69 +98,6 @@ This file provides settings for ESS and R.
(require 'ess-site)
#+end_src

** Make ESS support cacheSweave() library in R
ESS comes with support for Sweave, e.g.,: M-n s M-n P from the Rnw
file. But we also want to be able to conveniently use the
cacheSweave() library, which uses a different driver. So we need a
separate command for that. The following solution comes from [[http://blog.nguyenvq.com/2009/05/14/editingadding-on-to-sweave-features-in-ess/][Vinh
Nguyen]] and allows for cacheSweave() compilation with M-n w.

Note that unless you really need Sweave (.e.g, because you're writing R vignettes) then you can use Knitr instead, which includes its own caching support.

#+source: ess-cacheSweave
#+begin_src emacs-lisp :tangle no


(defun ess-swv-run-in-R2 (cmd &optional choose-process)
"Run \\[cmd] on the current .Rnw file. Utility function not called by user."
(let* ((rnw-buf (current-buffer)))
(if choose-process ;; previous behavior
(ess-force-buffer-current "R process to load into: ")
;; else
(update-ess-process-name-list)
(cond ((= 0 (length ess-process-name-list))
(message "no ESS processes running; starting R")
(sit-for 1); so the user notices before the next msgs/prompt
(R)
(set-buffer rnw-buf)
)
((not (string= "R" (ess-make-buffer-current))); e.g. Splus, need R
(ess-force-buffer-current "R process to load into: "))
))

(save-excursion
(ess-execute (format "require(tools)")) ;; Make sure tools is loaded.
(basic-save-buffer); do not Sweave/Stangle old version of file !
(let* ((sprocess (get-ess-process ess-current-process-name))
(sbuffer (process-buffer sprocess))
(rnw-file (buffer-file-name))
(Rnw-dir (file-name-directory rnw-file))
(Sw-cmd
(format
"local({..od <- getwd(); setwd(%S); %s(%S, cacheSweaveDriver()); setwd(..od) })"
Rnw-dir cmd rnw-file))
)
(message "%s()ing %S" cmd rnw-file)
(ess-execute Sw-cmd 'buffer nil nil)
(switch-to-buffer rnw-buf)
(ess-show-buffer (buffer-name sbuffer) nil)))))


(defun ess-swv-weave2 ()
"Run Sweave on the current .Rnw file."
(interactive)
(ess-swv-run-in-R2 "Sweave"))

(define-key noweb-minor-mode-map "\M-nw" 'ess-swv-weave2)

#+end_src



#+source: message-line
#+begin_src emacs-lisp
(message "Starter Kit Stats loaded.")
#+end_src
** Uniquify Buffer Names
This is useful for when you have buffers with many similar names, as when there are various open files from different folders named =analysis.R= or similar.

Expand Down

0 comments on commit 28b1b17

Please sign in to comment.