emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing a variable into an R source block.


From: William Denton
Subject: Re: Passing a variable into an R source block.
Date: Fri, 28 May 2021 15:29:33 -0400 (EDT)
User-agent: Alpine 2.22 (DEB 394 2020-01-19)

The Org table is passed in to R as a data.frame, so all you need is this at the start (with stringr loaded in previously):

#+begin_src R :session :colnames yes :var data=query
t <- str_split_fixed(data$te, " ", 3)
colnames(t) <- c('date','cycle','energy')
t
#+end_src

#+RESULTS:
|            date | cycle |         energy |
|-----------------+-------+----------------|
| 20210528-053900 |     1 | -1333.58106425 |
| 20210528-053900 |     2 | -1333.25006295 |
| 20210528-053900 |     3 | -1332.40596663 |
| 20210528-053900 |     4 |  -1327.1880297 |
| 20210528-053900 |     5 | -1320.63944318 |

Bill

--
William Denton
https://www.miskatonic.org/
Librarian, artist and licensed private investigator.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]