emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Hendy <jw.hendy@gmail.com>
To: news1142@karl-voit.at
Cc: emacs-orgmode@gnu.org
Subject: Re: Babel/R issue: 'x' must be atomic
Date: Thu, 23 Aug 2012 18:59:08 -0500	[thread overview]
Message-ID: <CA+M2ft-TfUHLfccfVGTSczYwUVnX55S4FFbRUtJhNssF8E8_Bg@mail.gmail.com> (raw)
In-Reply-To: <2012-08-24T01-13-00@devnull.Karl-Voit.at>

On Thu, Aug 23, 2012 at 6:23 PM, Karl Voit <devnull@karl-voit.at> wrote:
> Hi!
>
> Generating two separate boxplots for a given set of data is no problem. But
> when I combine them into one single diagram (with two boxplots), I get:
>
> Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) :
>   'x' must be atomic
> Calls: <Anonymous> ... boxplot.stats -> <Anonymous> -> sort -> sort.default -> sort.int
> Execution halted
>
>
> You can get the minimal example Org-mode on http://paste.grml.org/1036/
>
> When I replace the line
>             boxplot(list(folders, tags),
> with
>             boxplot(list(mfolders, mtags),
> it works, though :-O
>
> mfolders and mtags are lists in R and not imported via »:var«. Therefore I
> guess this is an Org-mode/babel issue and not an R issue. What is my error?
>
> Any help would be very cool!

Org must convert tables to data.frames, which is a problem for boxplot():

,----- ?boxplot -----
| x: for specifying data from which the boxplots are to be
|           produced. Either a numeric vector, or a single list
|           containing such vectors.
`-----

So, you need to pass a list of /vectors/, not a data.frame. Here's
what's going on:

#+begin_src R
> str(folders)
'data.frame':	10 obs. of  1 variable:
 $ V1: int  14 14 15 18 18 19 20 21 22 23
> str(mfolders)
 num [1:17] 4.3 3.72 5.1 4.03 5.7 ...
> str(tags)
'data.frame':	15 obs. of  1 variable:
 $ V1: int  1 3 3 3 3 3 4 4 4 4 ...
> str(mtags)
 num [1:15] 3.95 4.25 5.22 6.2 5.27 ...
#+end_src

So... folders is a data.frame with one numeric vector, V1. Same for
tags. For mfolder and mtags, you created a vector, not a data.frame.

Try this to pass the vectors from each data.frame:

#+begin_src R
boxplot(list(folders$V1, tags$V1),
    names=c("one", "two"),
    xlab="boxplot12",
    ylab="numbers",
    pars = list(boxwex = 0.3, staplewex = 0.5,
    boxfill="lightblue"))
#+end_src


That should work!
John

>
>
> PS: Org-mode version from git from yesterday
>
> --
> Karl Voit
>
>

  reply	other threads:[~2012-08-23 23:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-23 23:23 Babel/R issue: 'x' must be atomic Karl Voit
2012-08-23 23:59 ` John Hendy [this message]
2012-08-24  9:33   ` Karl Voit

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-TfUHLfccfVGTSczYwUVnX55S4FFbRUtJhNssF8E8_Bg@mail.gmail.com \
    --to=jw.hendy@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=news1142@karl-voit.at \
    /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).