From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Drake Subject: [0][babel][R] Undesired conversion of integers to floats in R code block output Date: Thu, 16 Feb 2012 11:07:02 -0800 Message-ID: <4F3D53D6.40407@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([140.186.70.92]:36566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ry6hd-0005GP-68 for emacs-orgmode@gnu.org; Thu, 16 Feb 2012 14:09:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ry6hS-00058s-Po for emacs-orgmode@gnu.org; Thu, 16 Feb 2012 14:09:13 -0500 Received: from mail-pw0-f41.google.com ([209.85.160.41]:59666) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ry6hS-00058d-L1 for emacs-orgmode@gnu.org; Thu, 16 Feb 2012 14:09:02 -0500 Received: by pbcwz17 with SMTP id wz17so3045626pbc.0 for ; Thu, 16 Feb 2012 11:09:01 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "emacs-orgmode@gnu.org" Hi All, I'm using R in org-mode/babel to analyze data from a psychological study. The subjects in this study are identified by nine digit integers (e.g., 987654321) that I treat as strings (or factors) in my R data frames. Tables output by an R code block that contain these subject IDs are not formatted properly: the subject IDs seem to be treated as numbers and a decimal point and a trailing zero are appended. For example, what should be | subj.id | |-----------| | 987654321 | becomes | subj.id | | 987654321.0 | (I've included real, self-contained code below.) When I write the data frames directly to a file from within the R code block (using a write.table function call that mimics the one in ob-R.el), the integer IDs are preserved; but when code from ob-R.el writes them out, the values get reformated as floats. I've noticed that eight digit integers are not modified in the same way, which makes me wonder if there is a 'digits' threshold I could modify to prevent this from happening. I've pretty much ruled out the possibility that this transformation occurs in R; however I'm not proficient enough in elisp to follow the operations that happen after the data frame is written to a file in the org-babel-R-write-object-command. Any pointers to help me figure this out would be very appreciated! (I've seen this thread: http://comments.gmane.org/gmane.emacs.orgmode/31373, but do not know if the conversion to calc has been made already or if it is the source of the problem.) Thanks, Dan I'm running: - Arch Linux (32 bit) - GNU Emacs 23.4.1 - Org-mode version release_7.8.03-351-g47eb3 - R version 2.14.1 (2011-12-22) * Test ** table as generated by org-mode/babel #+name: make #+begin_src R :results value :colnames yes temp <- data.frame('A'=c('987654321'),'B'=c('98765432')) ## -- this call mimics the one in ob-R.el write.table(temp,file='test_r.tsv',sep='\t',na='nil',row.names=FALSE,col.names=TRUE,quote=FALSE) temp #+end_src #+RESULTS: make | A | B | |-------------+----------| | 987654321.0 | 98765432 | ** table as generated by R directly #+name: read #+begin_src sh :results output cat test_r.tsv #+end_src #+RESULTS: read : A B : 987654321 98765432