From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id EO/qC0AE3l9sPAAA0tVLHw (envelope-from ) for ; Sat, 19 Dec 2020 13:46:40 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id oMSdB0AE3l8BZAAAbx9fmQ (envelope-from ) for ; Sat, 19 Dec 2020 13:46:40 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 784239400BF for ; Sat, 19 Dec 2020 13:46:39 +0000 (UTC) Received: from localhost ([::1]:37632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqcZC-0004dO-3I for larch@yhetil.org; Sat, 19 Dec 2020 08:46:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqcYU-0004bp-FD for emacs-orgmode@gnu.org; Sat, 19 Dec 2020 08:45:54 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:41123) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kqcYQ-0004ay-6u for emacs-orgmode@gnu.org; Sat, 19 Dec 2020 08:45:53 -0500 Received: by mail-wr1-x435.google.com with SMTP id a12so6011264wrv.8 for ; Sat, 19 Dec 2020 05:45:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=r7X0RTjo3gbmyacBFOZdRqXxKHc+CbJ865Qyvw0jVwg=; b=skDPPq/6lW9WJQYM/pEZpHRh2N7uoYCHEk3ktchIJMO9ycY8QanbIscqVqLyW/dD3B oJbHwIJxJyY7zaIIOtBWJ2xSeU8a/Nj00knR1WTiFWGTfTBmQKq9MAXtfGYKeeQTgfMX A8nMz+wdZqR7jdiDCDyueVIpJisiG/RoTMG7tDbkUozbSXWmpoiEgWLDgB+LTCgEpWlO Xqv8FXZEZBpmTTB6B3DGfu/zvmCvxvsKDeh4o/ODGynlZLBLrXn2BXOtEqSPChnGYKvB O+2YtZEsIdjxUmGMhJ9rG3gozezW0KKVn87OfNd2bjxsFxzwBQM9HsgAud6EIk4yarlY tZIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=r7X0RTjo3gbmyacBFOZdRqXxKHc+CbJ865Qyvw0jVwg=; b=m3h0kjNB0xWXwZjzJ4GAeyTSQLC/JxaEVn0fcUtTbL55vSvsV2QiWtdap+SfMdFnBh ESJ+eH8oD9Y+MTBM5TJ2B6mD3pK5wynqbv6d2X/ET9Bec8H0w3OGN0WcJ85ggZYb9qEQ 0eFyO3M6oFfihh0SsKL2opWGGJXj59oSUkV3wqt6DNjwSAVp6IrdVTjUT5fxYgV/KqXd SDFdte0sv8TxFVZOiyjOCY9PWB1spksaW48ClsF8Xo8Y4jox4H59mRJ3N4JUoozfj5SY zIheFugXy8E/WtwbqixpEmqjYie+ioduOi6InevjHXZQBRPuY77G+9t9vse1DfmZ5HdL ekBQ== X-Gm-Message-State: AOAM532CZa9wpyZmgVP8LdhKYV2KFoJsDgJ6xaney4v08PRO7vNGKOo0 o9tBMiy7WK0Fv5pJMuyYf6s= X-Google-Smtp-Source: ABdhPJwijQ/pOedS+SGVprGo0+SwAbqm5bVtaoDHGp0Oiai/Oz37PqIDJuV6KdoOhg6IiCj8xqYkew== X-Received: by 2002:adf:a34d:: with SMTP id d13mr9631453wrb.194.1608385548062; Sat, 19 Dec 2020 05:45:48 -0800 (PST) Received: from freegnu (91-170-171-121.subs.proxad.net. [91.170.171.121]) by smtp.gmail.com with ESMTPSA id m17sm20019991wrn.0.2020.12.19.05.45.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Dec 2020 05:45:47 -0800 (PST) From: Jeremie Juste To: Damien Cassou , emacs-orgmode@gnu.org Subject: Re: Bug: Babel+R handles spaces wrongly in tables [9.3.6 (release_9.3.6 @ /home/cassou/.emacs.d/lib/org/lisp/)] In-Reply-To: <87wo172laf.fsf@cassou.me> References: <87wo172laf.fsf@cassou.me> Date: Sat, 19 Dec 2020 14:45:46 +0100 Message-ID: <87mty99aet.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=jeremiejuste@gmail.com; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Berry, Charles" Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -1.52 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=skDPPq/6; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 784239400BF X-Spam-Score: -1.52 X-Migadu-Scanner: scn0.migadu.com X-TUID: 0vwxq7g5LE+/ Hello, Apologies for the late reply and thanks for pointing out this bug. || On Sunday, 6 Sep 2020 at 13:32, Damien Cassou wrote: #+name: table | | 2014 | |-----+------| | A C | 1 | | C | 2 | #+name: linechart #+begin_src R :results value :var accounts="" :exports none length(accounts) #+end_src #+call: linechart(accounts=table[,0]) #+RESULTS: : 3 Currently there are no support for vectors. So it is either a data.frame or an object of length 1. || On Sun, 06 Sep 2020 18:23:19 Berry, Charles" wrote > Actually the length should be 1, i.e. a data.frame with a single column of two elements. Indeed with the current handling the length should be 1 but it is not. Even with the previous case solved, it might still be an unexpected behavior for a typical R user who would expect a vector. Do you think it is reasonable? The following patch will at least harmonize the results towards the data.frame. diff --git a/lisp/ob-R.el b/lisp/ob-R.el index 420b8ccbc..81693d157 100644 --- a/lisp/ob-R.el +++ b/lisp/ob-R.el @@ -236,11 +236,11 @@ This function is called by `org-babel-execute-src-block'." (defun org-babel-R-assign-elisp (name value colnames-p rownames-p) "Construct R code assigning the elisp VALUE to a variable named NAME." (if (listp value) - (let* ((value (if (listp (car value)) value (list value))) - (lengths (mapcar 'length (cl-remove-if-not 'sequencep value))) + (let* ((lengths (mapcar 'length (cl-remove-if-not 'sequencep value))) (max (if lengths (apply 'max lengths) 0)) (min (if lengths (apply 'min lengths) 0))) ;; Ensure VALUE has an orgtbl structure (depth of at least 2). + (unless (listp (car value)) (setq value (list value))) (let ((file (orgtbl-to-tsv value '(:fmt org-babel-R-quote-tsv-field))) (header (if (or (eq (nth 1 value) 'hline) colnames-p) "TRUE" "FALSE")) so the following will return a data.frame #+begin_src R :results output :var accounts=(identity '("A B" "C")) print(accounts) #+end_src #+RESULTS: : V1 V2 : 1 A B C I will add support for selection of 1 single column as a vector soon. Best regards, Jeremie PS: I am a newbie maintainer so feel free to comment if there you find room for improvements ;-)