From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Drake Subject: Re: [0][babel][R] Undesired conversion of integers to floats in R code block output Date: Sat, 18 Feb 2012 23:02:43 -0800 Message-ID: <4F409E93.5010800@gmail.com> References: <4F3D53D6.40407@gmail.com> <87boowrtyv.fsf@gmx.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]:56332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rz0pU-0000bL-Hh for emacs-orgmode@gnu.org; Sun, 19 Feb 2012 02:05:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rz0pS-0008EZ-Bc for emacs-orgmode@gnu.org; Sun, 19 Feb 2012 02:05:04 -0500 Received: from mail-pw0-f41.google.com ([209.85.160.41]:55362) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rz0pR-0008E3-JD for emacs-orgmode@gnu.org; Sun, 19 Feb 2012 02:05:02 -0500 Received: by pbcwz17 with SMTP id wz17so5516231pbc.0 for ; Sat, 18 Feb 2012 23:04:59 -0800 (PST) In-Reply-To: <87boowrtyv.fsf@gmx.com> 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: Eric Schulte Cc: "emacs-orgmode@gnu.org" On 02/18/2012 08:23 AM, Eric Schulte wrote: > Daniel Drake writes: > >> 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.) >> > > Hi Dan, > > When I launch Emacs without any personal configuration (emacs -Q), > evaluate ob-R.el to add R support, and then execute your code blocks I > get the following behavior. > > > > > > I would recommend installing the latest version of Org-mode from source > as that tends to fix many problems, and will at least ensure that we are > both working from the same code base moving forward. See > http://orgmode.org/worg/org-faq.html#Keeping-current > > Best, > Hi Eric, First of all, thanks for your reply. Just to be safe, I nuked my org-mode directory and re-cloned from the git repository: I'm now at release_7.8.03.386.g2239d (I was at release_7.8.03-351-g47eb3 previously). Is there a more recent version? I also removed the org directory that came with the packaged version of emacs, just in case. I start emacs with the following options: $ emacs -Q -eval '(setq load-path (cons "~/share/emacs/site-lisp/org-mode/lisp" load-path))' -eval "(require 'ob-R)" test.org I get the same behavior as before. I was a little puzzled when I saw this happen, as I've been working on this study for over a year in org and it's the first time I've seen this behavior. I went back and tried previous versions (e.g., 7.4), and now I see the same thing. I wonder if Arch (a rolling release linux distribution that tries to be close to the leading edge) has updated an underlying library that impacts the babel code in some odd way. (Granted, I don't see how this could be, as the emacs environment seems pretty well insulated from the underlying OS; PEBKAC just as likely.) In any event, since you can't reproduce the behavior (thanks again for trying), I don't expect it's anything you can fix. Maybe it will show up in other distributions as they update to more current versions. In the mean time, I'll try to improve my elisp skills and figure out where the extraneous formatting occurs. Best, Dan - GNU Emacs 23.4.1 (i686-pc-linux-gnu, GTK+ Version 2.24.9) of 2012-02-01 on shirley.hoetzel.info - Org-mode version 7.8.03 (release_7.8.03.386.g2239d)