emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* R contingency table axes labels in org
@ 2013-11-04 16:05 Jarmo Hurri
  2013-11-04 16:52 ` Thomas S. Dye
  0 siblings, 1 reply; 3+ messages in thread
From: Jarmo Hurri @ 2013-11-04 16:05 UTC (permalink / raw)
  To: emacs-orgmode


Greetings again.

I need to represent a contingency table generated by R in an org file. R
output shows the labes of the vertical and the horizontal axes, but
these are pruned from the output in org-mode. Is there a nice way to
reintroduce the axes labels?

# ----------------------------------------------------------------------
* interesting data
  #+BEGIN_SRC R :exports results :rownames yes :colnames yes
    org.files <- c (1, 0, 2, 2, 2, 2, 1)
    happiness <- c (1, 0, 2, 2, 2, 1, 2)
    data <- data.frame (org.files, happiness)
    table (data)
  #+END_SRC

  #+RESULTS:
  |   | 0 | 1 | 2 |
  |---+---+---+---|
  | 0 | 1 | 0 | 0 |
  | 1 | 0 | 1 | 1 |
  | 2 | 0 | 1 | 3 |
# ----------------------------------------------------------------------

All the best,

Jarmo

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

* Re: R contingency table axes labels in org
  2013-11-04 16:05 R contingency table axes labels in org Jarmo Hurri
@ 2013-11-04 16:52 ` Thomas S. Dye
  2013-11-04 17:30   ` Jarmo Hurri
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas S. Dye @ 2013-11-04 16:52 UTC (permalink / raw)
  To: Jarmo Hurri; +Cc: emacs-orgmode

Jarmo Hurri <jarmo.hurri@syk.fi> writes:

> Greetings again.
>
> I need to represent a contingency table generated by R in an org file. R
> output shows the labes of the vertical and the horizontal axes, but
> these are pruned from the output in org-mode. Is there a nice way to
> reintroduce the axes labels?
>
> # ----------------------------------------------------------------------
> * interesting data
>   #+BEGIN_SRC R :exports results :rownames yes :colnames yes
>     org.files <- c (1, 0, 2, 2, 2, 2, 1)
>     happiness <- c (1, 0, 2, 2, 2, 1, 2)
>     data <- data.frame (org.files, happiness)
>     table (data)
>   #+END_SRC
>
>   #+RESULTS:
>   |   | 0 | 1 | 2 |
>   |---+---+---+---|
>   | 0 | 1 | 0 | 0 |
>   | 1 | 0 | 1 | 1 |
>   | 2 | 0 | 1 | 3 |
> # ----------------------------------------------------------------------
>
> All the best,
>
> Jarmo
>
>
>

library(ascii)
...
print(ascii(table(data)), type="org")

hth,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: R contingency table axes labels in org
  2013-11-04 16:52 ` Thomas S. Dye
@ 2013-11-04 17:30   ` Jarmo Hurri
  0 siblings, 0 replies; 3+ messages in thread
From: Jarmo Hurri @ 2013-11-04 17:30 UTC (permalink / raw)
  To: emacs-orgmode

tsd@tsdye.com (Thomas S. Dye) writes:

> library(ascii)
> ...
> print(ascii(table(data)), type="org")

Great tip. I even got the result out as an interpreted org table by
using ":results output raw". (For example, without "raw" it becomes
literal.) Thanks!

* interesting data
  #+BEGIN_SRC R :exports results :results output raw
    library (ascii)
    org.files <- c (1, 0, 2, 2, 2, 2, 1)
    happiness <- c (1, 0, 2, 2, 2, 1, 2)
    data <- data.frame (org.files, happiness)
    print (ascii (table (data)), type = "org")
  #+END_SRC

  #+RESULTS:
  |             |   | *happiness* |      |      |
  |             |   |           0 |    1 |    2 |
  |-------------+---+-------------+------+------|
  | *org.files* | 0 |        1.00 | 0.00 | 0.00 |
  |             | 1 |        0.00 | 1.00 | 1.00 |
  |             | 2 |        0.00 | 1.00 | 3.00 |


Jarmo

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

end of thread, other threads:[~2013-11-04 17:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-04 16:05 R contingency table axes labels in org Jarmo Hurri
2013-11-04 16:52 ` Thomas S. Dye
2013-11-04 17:30   ` Jarmo Hurri

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