emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Problem with R source blocks
@ 2015-06-11 23:12 Thomas S. Dye
  2015-06-12 18:50 ` Charles C. Berry
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas S. Dye @ 2015-06-11 23:12 UTC (permalink / raw)
  To: emacs-orgmode

Aloha all,

Recently, some previously working R code (below) stopped working correctly.

It is not possible to produce a graphic without :session.  I get a red
message in the pdf file "arguments imply differing numbers of rows: 86,
79".

With :session, I first get one of two error messages in red in the pdf
file, either "Results must be all atomic, or all data frames" or
"subscript out of bounds".

With the "subscript out of bounds" error, if I run the source code block
again, I get the expected graphic.

With the "Results must be all atomic ..." message, if I re-run the
source code block several times, I see first an error "arguments imply
differing numbers of rows: 67, 60", then on the next run "arguments imply
differing numbers of rows: 86, 79" (like running outside a :session),
then the expected graphic.  Subsequent runs all produce the expected
graphic.

If I jump to the session, then print(g) works as expected, without any
error messages.

I haven't the faintest idea what might be happening, or how to debug.

#+begin_src emacs-lisp
(org-version)
#+end_src

#+results:
: 8.3beta

#+begin_src emacs-lisp
(emacs-version)
#+end_src

#+results:
: GNU Emacs 24.5.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21)
:  of 2015-04-18 on tennine-slave.macports.org

All the best,
Tom

,-------------------------------------------------------------------------
| #+name: dated-interval-plot                                             
| #+header: :file ~/temp/test-plot.pdf                                    
| #+header: :var bcal = heiau-dates                                       
| #+header: :var base.font = 11                                           
| #+header: :var theme = "bw"                                             
| #+header: :var xlabel = "Years After Polynesian Discovery"              
| #+header: :var ylabel = "Probability"                                   
| #+header: :var rows=4                                                   
| #+header: :var cols=4                                                   
| #+header: :var xmin=0                                                   
| #+header: :var xmax=1000                                                
| #+header: :width 7 :height 5                                            
| #+header: :results graphics                                             
| #+BEGIN_SRC R :session                                                  
| library(ggplot2)                                                        
| library(ggthemes)                                                       
| bcal.df <- data.frame(cal=numeric(0),prob=numeric(0),label=character(0))
| for (i in seq(dim(bcal)[1]))                                            
| {                                                                       
|  t <- read.csv(file=bcal[i,1])                                          
|  names(t) <- c("cal","prob")                                            
|  t <- cbind(t,label=rep(bcal[i,2], dim(t)[1]))                          
|  bcal.df <- rbind(bcal.df,t)                                            
| }                                                                       
| switch(theme,                                                           
|     bw =, BW = theme_set(theme_bw(base_size=base.font)),                
|     grey =, gray = theme_set(theme_grey(base_size=base.font)),          
|     tufte = theme_set(theme_tufte(base_size=base.font)),                
|     calc = theme_set(theme_calc(base_size=base.font)),                  
|     econ =, economist = theme_set(theme_economist(base_size=base.font)),
|     excel = theme_set(theme_excel(base_size=base.font)),                
|     few = theme_set(theme_few(base_size=base.font)),                    
|     five = theme_set(theme_fivethirtyeight(base_size=base.font)),       
|     google =, gdocs = theme_set(theme_gdocs(base_size=base.font)),      
|     ## highchart =, hc = theme_set(theme_hc(base_size=base.font)),      
|     inverted = theme_set(theme_igray(base_size=base.font)),             
|     solarized = theme_set(theme_solarized(base_size=base.font)),        
|     solarized2 = theme_set(theme_solarized_2(base_size=base.font)),     
|     ## solid = theme_set(theme_solid(base_size=base.font)),             
|     stata = theme_set(theme_stata(base_size=base.font,scheme="s2mono")),
|     wsj = theme_set(theme_wsj(base_size=base.font)),                    
|     theme_set(theme_bw(base_size=base.font)))                           
| g <-  ggplot(bcal.df, aes(x=cal, y=prob))                               
| g <- g + geom_bar(stat='identity') + xlab(xlabel) + xlim(xmin,xmax)     
| g <- g + ylab(ylabel) + facet_wrap(~ label, nrow=rows, ncol=cols)       
| print(g)                                                                
| #+END_SRC                                                               
`-------------------------------------------------------------------------

-- 
T.S. Dye & Colleagues, Archaeologists
735 Bishop St, Suite 315, Honolulu, HI 96813
Tel: 808-529-0866, Fax: 808-529-0884
http://www.tsdye.com

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

end of thread, other threads:[~2015-06-13  0:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-11 23:12 Problem with R source blocks Thomas S. Dye
2015-06-12 18:50 ` Charles C. Berry
2015-06-12 21:55   ` Thomas S. Dye
2015-06-12 22:33     ` Charles C. Berry
2015-06-12 23:54       ` Thomas S. Dye
2015-06-13  0:26         ` Thomas S. Dye

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