emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: William Denton <wtd@pobox.com>
To: Roger Mason <rmason@mun.ca>
Cc: emacs-orgmode@gnu.org
Subject: Re: Passing a variable into an R source block.
Date: Fri, 28 May 2021 15:29:33 -0400 (EDT)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2105281527000.60852@shell3.miskatonic.org> (raw)
In-Reply-To: <y658s3y4zzn.fsf@mun.ca>

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.


      parent reply	other threads:[~2021-05-28 19:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-28 15:52 Passing a variable into an R source block Roger Mason
2021-05-28 17:30 ` Berry, Charles via General discussions about Org-mode.
2021-05-29 14:13   ` Roger Mason
2021-05-28 19:29 ` William Denton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.22.394.2105281527000.60852@shell3.miskatonic.org \
    --to=wtd@pobox.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=rmason@mun.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).