emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Babel/R issue: 'x' must be atomic
@ 2012-08-23 23:23 Karl Voit
  2012-08-23 23:59 ` John Hendy
  0 siblings, 1 reply; 3+ messages in thread
From: Karl Voit @ 2012-08-23 23:23 UTC (permalink / raw)
  To: emacs-orgmode

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!


PS: Org-mode version from git from yesterday

-- 
Karl Voit

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Babel/R issue: 'x' must be atomic
  2012-08-23 23:23 Babel/R issue: 'x' must be atomic Karl Voit
@ 2012-08-23 23:59 ` John Hendy
  2012-08-24  9:33   ` Karl Voit
  0 siblings, 1 reply; 3+ messages in thread
From: John Hendy @ 2012-08-23 23:59 UTC (permalink / raw)
  To: news1142; +Cc: emacs-orgmode

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
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Babel/R issue: 'x' must be atomic
  2012-08-23 23:59 ` John Hendy
@ 2012-08-24  9:33   ` Karl Voit
  0 siblings, 0 replies; 3+ messages in thread
From: Karl Voit @ 2012-08-24  9:33 UTC (permalink / raw)
  To: emacs-orgmode

* John Hendy <jw.hendy@gmail.com> wrote:
>
> So, you need to pass a list of /vectors/, not a data.frame. Here's
> what's going on:

[...]

> 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:
[...]

Great explanation, I understand what I did wrong, and it works now.

Thank you very much!

-- 
Karl Voit

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-08-24  9:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-23 23:23 Babel/R issue: 'x' must be atomic Karl Voit
2012-08-23 23:59 ` John Hendy
2012-08-24  9:33   ` Karl Voit

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).