[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] R code not producing expected results

From: Thomas S. Dye
Subject: Re: [Orgmode] R code not producing expected results
Date: Thu, 12 Aug 2010 20:23:14 -1000

Aloha Marco,

Here is the code behind the Worg page:

#+begin_src R :results output org
  ascii(summary(table(1:4, 1:4)))

This works here.

The key seems to be the header argument :results output

#+BEGIN_SRC R :results output

 d <- as.data.frame(replicate(4,rnorm(100)))

 ascii(cor(d),include.rownames=T, include.colnames=T,header=T)


   Welcome to R!

|    | V1   | V2    | V3    | V4    |
| V1 | 1.00 | 0.09  | 0.09  | 0.13  |
| V2 | 0.09 | 1.00  | -0.00 | -0.13 |
| V3 | 0.09 | -0.00 | 1.00  | 0.18  |
| V4 | 0.13 | -0.13 | 0.18  | 1.00  |

With it added to your other example, it does indeed generate a nice table.

I think you are absolutely right about org-mode's babel capabilities helping with your R work. I can't imagine a better environment for working in R.

Good luck with your work.

All the best,

On Aug 12, 2010, at 6:32 PM, Blanchette, Marco wrote:

Dear all,

Sorry if this is something totally obvious but I am learning to use org-mode for my everyday work with R. I just installed the latest stable release of org-mode (v7.01g) on top of GNU Emacs (x86_64-apple-darwin10.2.0, NS apple-appkit-1038.25). I also installed the CRAN ascii package v0.7 on top of R v2.11.1. I am currently working on a MacBook pro with Snow Leopard 10.6.4

Early on today, while reading the org-babel intro, I was able to run the following example but somehow, later tonight, it started to break and I spent the last few hours scratching my head to understand what change and why it now suddenly break. Your help will be greatly appreciated as I am discovering that org-mode in collaboration with org-babel have great potential to help us create more readable report of our daily analysis, as long as I can get through these early hurdles.

Here is the org buffer that now breaks:

* Two examples of R code that worked when I started the tutorial but suddenly started to fail...

** some R code that should generate a nice table

 d <- as.data.frame(replicate(4,rnorm(100)))

 ascii(cor(d),include.rownames=T, include.colnames=T,header=T)

** Some code straight from [[http://orgmode.org/worg/org-contrib/babel/languages/org-babel-doc-R.php ][org-babel]]
ascii(summary(table(1:4, 1:4)))

With the following error recover from the *Org-Babel Error* buffer

Loading required package: proto
Error in as.data.frame.default(x[[i]], optional = TRUE) :
cannot coerce class 'c("ascii", "proto", "environment")' into a data.frame Calls: write.table ... data.frame -> as.data.frame -> as.data.frame.default
Execution halted

Thanks for the helps.
Marco Blanchette, Ph.D.
Assistant Investigator
Stowers Institute for Medical Research
1000 East 50th St.

Kansas City, MO 64110

Tel: 816-926-4071
Cell: 816-726-8419
Fax: 816-926-2018

Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]