From: John Hendy <firstname.lastname@example.org> To: emacs-orgmode <email@example.com> Subject: Re: R terminal output does not match src block output due to ">" character in results Date: Tue, 11 Jan 2022 17:30:41 -0600 [thread overview] Message-ID: <CA+M2ft-TFHa7cy43-1-WpFr6weYp2ZU0uwiVoUpuo-1kTR93=Q@mail.gmail.com> (raw) In-Reply-To: <CA+M2ft-AmM8+d-pOW6-+N19QmCm790Lbqbgkh4w3fvRJMMhFGg@mail.gmail.com> Ok, after more searching, I found that this is a duplicate issue that's already been discussed. Not sure why all my incantations didn't bring me to the reddit post or mailing list from google, but simply searching "prompt blocks R" on r/orgmode directly got me here: https://www.reddit.com/r/orgmode/comments/pt3em4/source_block_modifying_format_of_results_r/ And that links to a patch: https://gist.github.com/gtuckerkellogg/e356d20497cfdc8e4fc683412e320e3e And that points to this mailing list thread where the topic has already come up: https://firstname.lastname@example.org/ It appears the discussion/fix is stalled out at this point? Best regards, John On Tue, Jan 11, 2022 at 4:42 PM John Hendy <email@example.com> wrote: > > I just ran into an issue where results look fine in the terminal, but > not in the results of a source block. I can't share the real example > as it's work confidential, but a couple of rows across 7 columns looks > like this in the terminal: > > #+begin_example terminal > dbGetQuery(con, paste0("SELECT TOP 2 * FROM table")) > 1 <NA> NA NA <NA> FALSE 0 5 > 2 <NA> NA NA <NA> FALSE 0 5 > #+end_example > > When I use this with :exports results :results output drawer in my > document, I get: > #+begin_example src > 1 < > NA NA < > FALSE 0 5 > 2 < > NA NA < > FALSE 0 5 > #+end_example > > I had an entirely separate email written and about to send, when it > dawned on me that the > character is the same as the R terminal prompt > and might be the cause. > > My first attempt to reproduce was unsuccessful: > > #+begin_src R :session :exports results :results output drawer > df <- data.frame( > x = letters[1:3], > y = c(1, 2, NA), > z = c("x", NA,"z")) > df > #+end_src > > #+RESULTS: > :results: > x y z > 1 a 1 x > 2 b 2 <NA> > 3 c NA z > :end: > > I'm not sure if it's about more columns or more rows, but this does the trick: > > #+begin_src R :session :exports results :results output drawer > df <- data.frame( > x = letters[1:7], > y = c(1, 2, NA, NA, NA, NA, NA), > z = c("x", NA, NA, NA, NA, NA, "z"), > a = c(1, rep(NA, 6))) > df > #+end_src > > #+RESULTS: > :results: > x y z a > 1 a 1 x 1 > 2 b 2 < > NA > 3 c NA < > NA > ### ... shortened > :end: > > If you comment out the line with z=, it works again... but that's the > column with all the <NA> values. Then again, if you end the data.frame > at z and don't add column a, it *also* works despite the presence of > many <NA> values. > > #+RESULTS: > :results: > x y z > 1 a 1 x > 2 b 2 <NA> > 3 c NA <NA> > ### ... shortened > :end: > > I'm imagining there's a... "parser?" somewhere that typically strips > off the command prompt from the results perhaps (and recall some vague > memory of someone telling me this years ago on the list). Is there a > way to stop this from happening? > > Would this line be responsible, or something else? > https://github.com/bzg/org-mode/blob/main/lisp/ob-R.el#L453 > > > Many thanks, > John
next prev parent reply other threads:[~2022-01-11 23:32 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-01-11 22:42 John Hendy 2022-01-11 23:30 ` John Hendy [this message] 2022-01-16 13:30 ` Jeremie Juste 2022-01-17 0:48 ` John Hendy 2022-01-24 4:49 ` Jack Kamm 2022-01-25 17:46 ` John Hendy
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='CA+M2ft-TFHa7cy43-1-WpFr6weYp2ZU0uwiVoUpuo-1kTR93=Q@mail.gmail.com' \ --firstname.lastname@example.org \ --email@example.com \ --subject='Re: R terminal output does not match src block output due to ">" character in results' \ /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
Code repositories for project(s) associated with this 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).