From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id yPhEBFYZ0WDorwAAgWs5BA (envelope-from ) for ; Tue, 22 Jun 2021 00:57:26 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id uHCWO1UZ0WBTfwAA1q6Kng (envelope-from ) for ; Mon, 21 Jun 2021 22:57:25 +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 5F729116BB for ; Tue, 22 Jun 2021 00:57:25 +0200 (CEST) Received: from localhost ([::1]:46256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvSr5-0001ty-BU for larch@yhetil.org; Mon, 21 Jun 2021 18:57:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvSqZ-0001tc-62 for emacs-orgmode@gnu.org; Mon, 21 Jun 2021 18:56:51 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:35639) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvSqX-0000Le-GB for emacs-orgmode@gnu.org; Mon, 21 Jun 2021 18:56:50 -0400 Received: by mail-pf1-x429.google.com with SMTP id t32so3479285pfg.2 for ; Mon, 21 Jun 2021 15:56:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:subject:date:in-reply-to:message-id :mime-version; bh=Z+18a1mq5R05vQgvDLoSizoySRkA93nhdP6X8pmQSPo=; b=FdHRdGqDthu/pgpyKMDQw12nFCEArW9wPF+X+tF29fjNRcB8l3d3SJxRsMojvTZdbJ h8/wfJp7WDLCD0TS+xLi+C2/JnP2JCfSd2q71N9KhoMLACQ9imStDw8ivRVeKQkOlvYq VIXhBotxSdGGPY1usQpcibtPE7TM+AenXQi9oCpMNv28SAh6TnXS0C8pug6r9z7Tipd5 svNdF2cZ+uubIL6lTZGjiMuh7IytOgvKsB99d095XzfsD6mOaS2c2NhVCeLxY++04nDR vnjqHnjW5tQ1Rb11ajCIINrqFYfM1NfpOHeIv31jOb6u44sIdp2b+soGPgPQhGralR7S n30w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:subject:date :in-reply-to:message-id:mime-version; bh=Z+18a1mq5R05vQgvDLoSizoySRkA93nhdP6X8pmQSPo=; b=feSBdeEp+wWqgN3ki1q/wKTWXBxW7hosRhrgSJCAyFtqiniJa71w95CVKrkBD4nuKl 8ZBOi9j+pxDIHAX19yId5wLHn65zBMQ9Rqf+g0F6vWzQ/LH+Avf5vAq3XKfOzQBoyHTf 2mATxRFF7g0D3Rtyjq+3UrW+uFi4pymxLrnYD+neNJJGvBWediFBy+/IOuffoNxjVoL9 o2Wk/UhqF2pxM6/0g+7EdJpkJdTu9AUcWXMJNKVaZS7mNAB53YvUJucSAsG8u0ymbyGJ Hm9rJUF1ubOLnZR5J2ePHw2yACBZ4mHHo7ZsHLLxZu19Eu9Qg5E+5QOXq5IJd7h0ko25 WxGg== X-Gm-Message-State: AOAM533rPNdbvQU96g/2j/2fa66oAP5vjTsdfFb1+bNjX3eg15dnNVcN KMebJZVOtrReUp7Com1YJusO1SBroEg= X-Google-Smtp-Source: ABdhPJywfA0WloMZxUA6rWg0zx8GMts31G90NDvlC00wWQK8cfnXRVAKd1ksIk9VU6v/1HMxOXKRRA== X-Received: by 2002:a63:3dcb:: with SMTP id k194mr771134pga.202.1624316206831; Mon, 21 Jun 2021 15:56:46 -0700 (PDT) Received: from tim-desktop (106-69-79-105.dyn.iinet.net.au. [106.69.79.105]) by smtp.gmail.com with ESMTPSA id v15sm16323672pfm.216.2021.06.21.15.56.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 15:56:46 -0700 (PDT) References: <874kdri7h6.fsf@mat.ucm.es> User-agent: mu4e 1.5.13; emacs 28.0.50 From: Tim Cross To: emacs-orgmode@gnu.org Subject: Re: table: problem with nan and if Date: Tue, 22 Jun 2021 08:26:40 +1000 In-reply-to: <874kdri7h6.fsf@mat.ucm.es> Message-ID: <87o8byltcl.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=theophilusx@gmail.com; helo=mail-pf1-x429.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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1624316245; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Z+18a1mq5R05vQgvDLoSizoySRkA93nhdP6X8pmQSPo=; b=NvrlOcbj6YR6NsjDB9z4pt5esX9F2OwNlOQUxMvdG1/oLzpNy/PeXds53eYtR9nMu4VfE2 17RA3f4O5TDkEfEecf8hCmnJFEp+RTNx1B0ZSacXNjpY+uruMtgQ2xChQDU9QunDR7ipPx gEl9sj8HIhJpJBy5uoaCimv4s61NiKmeycm+Wqxkf0ixdLA5Nu/jKlxVku87vjE+LL6w3A w3sxpIm5dpDGkMAMitDXjT4DlQVcF7w1PU0G1Ub96UUQY6NH02AUtLkV20c0ABeWY1ESIz JgxavaTlFCZCDvZRjzkhi04HTK9YF3gzn9zn0g8CGHOBARQMQKQ+OPCR4y1UYA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1624316245; a=rsa-sha256; cv=none; b=cacG4wfYxbiJ9d2ExQ3weNXI+Pz0TCJ07+XrXTSaegQP0eT8nxthCaqObZ9ofU5y4zuAoq Iaou8BNMnVZP97B/Gk5vsmattlbx2Df8gsVDOCCAYocFe+/uJ8En81Jyl9OjJbktmNDwxj EdR8Dd5ESFOBXbl9ee3A8TrzViq4qZ72guGqkceqTbDDKucK/QsQ3hbLwoxON2hsrUVFgu qF10xfeO0Bl+mJ27cSztfgZ/1WiPRfFgZJqN96E4Iov+vxFSSmh6R7O5skpygbdoPIfy3Z foC6jQcaq9hNVAatdLYM09CgjkLjKfhxQ2qOH6InssO0mxTLVfekBepOvjthYg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=FdHRdGqD; 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-Spam-Score: -1.62 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=FdHRdGqD; 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: 5F729116BB X-Spam-Score: -1.62 X-Migadu-Scanner: scn1.migadu.com X-TUID: M5f7AsNeXkfP Uwe Brauer writes: > Hi > > I have the following table > > #+begin_src elisp > #+NAME: test > | Name | E1 | E2 | E3 | Result1 | Result2 | Final | > |-------+----+----+-----+---------+---------+-------| > | User1 | | | | | 8 | nan | > | User2 | | | | | | | > | User3 | 1 | 0 | 3.5 | 4.5 | 5.8 | 4.8 | > |-------+----+----+-----+---------+---------+-------| > #+TBLFM: $5=if(typeof(vsum($2..$4)) == 12, string(" "),vsum($2..$4));E f-1::$7=if("$6" == "nan", string(" "),0.3*$5+0.6*$6); E f-1 > #+end_src > > > The calculations for User2 and 3 are fine, but for User1, the final > result is a "nan". > > I see the problem is caused by ; E f-1 I don't understand why because > > As in > > #+begin_src elisp > | user1 | User2 | | > |-------+-------+-----| > | | 3 | nan | > | 0 | 1 | 0.8 | > #+TBLFM: $3=0.2*$1+0.8*$2; E f-1 > #+end_src > > I am not sure, but should I use something like > > if("$5" == "nan", string(" "),0.6*$6); E;f-1 > > > But how can I combine both ifs, I am puzzled > > Any help is strongly appreciated. > > I'm not very familiar with calc, but am wondering if the issue is the 'nan'. In many languages, a nan is a 'polluting' variable i.e. once you have a nan as a form anywhere in your calculation, the result will always be a nan. Many languages actually have a special function to test for a nan because it isn't actually a 'value'. Don't know if this is the case with calc. Perhaps an alternative strategy might help. Could you address what is generating the nan and change that so that it generates something else, possibly even a blank string and avoid the nan altogether? -- Tim Cross