Skip to main content
Bumped by Community user
Bumped by Community user
added 61 characters in body; edited tags
Source Link
mutbuerger
  • 3.5k
  • 15
  • 22
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 1781 characters in body
Source Link
DJJ
  • 770
  • 5
  • 19

** Some details ** Let's say that we are in an .org buffer and I have a buffer wide header like the following. With the session name being remote-R-remote* and the ouput being silenced :output silent

 #+PROPERTY: header-args:R :session *remote-R-remote*  :exports results :colnames yes :results output silent :output-dir images/ :dir "/ssh:gnu:/home/livelygnu/Documents/R/" :eval yes :cache yes
 
* Some First steps

    #+Name: 
    #+BEGIN_SRC R 
    do some stuffs
    #+END_SRC

Now if in a subtree we want to produce a certain number of graphs but don't want to write :results output graphics all the time along with the file extension we have to redefine the whole header argument for this subtree.

** output some graphs
:PROPERTIES:
:header-args:R: :session *remote-R-remote* :results output graphics :output-dir: images/ :eval yes :file-ext pdf
:END:

    #+Name: name_of_graphs
    #+BEGIN_SRC R 
    plot(a)
    #+END_SRC
    
    many more graphs possibly

We can do the same for latex output for example

** output some results
:PROPERTIES:
:header-args:R: :session *remote-R-remote* :results output latex :output-dir: 
:END:


#+Name: name_of_graphs
#+BEGIN_SRC R 
output latex block
#+END_SRC

Now let's say while our estimation is working on the session remote-R-remote (possibly a long computation), we want to continue to work on some graphs in another session. for that we would have to change the :session names for all the code block that we need. But If instead we modify the default arguments in org-babel-default-header-args. Then changing the key :session there would change the session everywhere. Of course this mean that we would not have to write :session *remote-R-remote* all the time as well since we can put it as default.

** Some details ** Let's say that we are in an .org buffer and I have a buffer wide header like the following. With the session name being remote-R-remote* and the ouput being silenced :output silent

 #+PROPERTY: header-args:R :session *remote-R-remote*  :exports results :colnames yes :results output silent :output-dir images/ :dir "/ssh:gnu:/home/livelygnu/Documents/R/" :eval yes :cache yes
 
* Some First steps

    #+Name: 
    #+BEGIN_SRC R 
    do some stuffs
    #+END_SRC

Now if in a subtree we want to produce a certain number of graphs but don't want to write :results output graphics all the time along with the file extension we have to redefine the whole header argument for this subtree.

** output some graphs
:PROPERTIES:
:header-args:R: :session *remote-R-remote* :results output graphics :output-dir: images/ :eval yes :file-ext pdf
:END:

    #+Name: name_of_graphs
    #+BEGIN_SRC R 
    plot(a)
    #+END_SRC
    
    many more graphs possibly

We can do the same for latex output for example

** output some results
:PROPERTIES:
:header-args:R: :session *remote-R-remote* :results output latex :output-dir: 
:END:


#+Name: name_of_graphs
#+BEGIN_SRC R 
output latex block
#+END_SRC

Now let's say while our estimation is working on the session remote-R-remote (possibly a long computation), we want to continue to work on some graphs in another session. for that we would have to change the :session names for all the code block that we need. But If instead we modify the default arguments in org-babel-default-header-args. Then changing the key :session there would change the session everywhere. Of course this mean that we would not have to write :session *remote-R-remote* all the time as well since we can put it as default.

added 17 characters in body; edited tags
Source Link
Drew
  • 79.1k
  • 10
  • 123
  • 257

I would like to have more control on the R session in org-mode so that I only have to chage the session name in one place for the modification to affect the whole buffer. The only way I could think this through was to modify the org-babel-default-header-args.

I want to define a function so that I can modify the default arguments easily. But I don't know how to pass the name of the session as a string. see the code below.

(defun set-session-name (&optional r-session-name r-session-directory)
  (interactive (list
                (read-from-minibuffer "r-session-name: " "*R*" )
        (read-from-minibuffer "r-session-directory: " "/home/test/")))  
  (setq org-babel-default-header-args:R
    (cons '(:dir . "%s" r-session-directory))
    (cons '(:session . r-session-name) 
          (assq-delete-all :session org-babel-default-header-args:R))
          ))

(:dir . "%s" ression directory "/home/test/") is obviously wrong. Can you help please?

I would like to have more control on the R session in org-mode so that I only have to chage the session name in one place for the modification to affect the whole buffer. The only way I could think this through was to modify the org-babel-default-header-args.

I want to define a function so that I can modify the default arguments easily. But I don't know how to pass the name of the session as a string. see the code below.

(defun set-session-name (&optional r-session-name r-session-directory)
  (interactive (list
                (read-from-minibuffer "r-session-name: " "*R*" )
        (read-from-minibuffer "r-session-directory: " "/home/test/")))  
  (setq org-babel-default-header-args:R
    (cons '(:dir . "%s" r-session-directory))
    (cons '(:session . r-session-name) 
          (assq-delete-all :session org-babel-default-header-args:R))
          ))

(:dir . "%s" ression directory "/home/test/") is obviously wrong. Can you help please?

I would like to have more control on the R session in org-mode so that I only have to chage the session name in one place for the modification to affect the whole buffer. The only way I could think this through was to modify the org-babel-default-header-args.

I want to define a function so that I can modify the default arguments easily. But I don't know how to pass the name of the session as a string. see the code below.

(defun set-session-name (&optional r-session-name r-session-directory)
  (interactive (list
                (read-from-minibuffer "r-session-name: " "*R*" )
        (read-from-minibuffer "r-session-directory: " "/home/test/")))  
  (setq org-babel-default-header-args:R
    (cons '(:dir . "%s" r-session-directory))
    (cons '(:session . r-session-name) 
          (assq-delete-all :session org-babel-default-header-args:R))
          ))

(:dir . "%s" ression directory "/home/test/") is obviously wrong. Can you help please?

Source Link
DJJ
  • 770
  • 5
  • 19
Loading