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 ms0.migadu.com with LMTPS id 8Hb8HpKq5mB7gAEAgWs5BA (envelope-from ) for ; Thu, 08 Jul 2021 09:34:42 +0200 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 MKepGpKq5mBTcgAAbx9fmQ (envelope-from ) for ; Thu, 08 Jul 2021 07:34:42 +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 71F0024949 for ; Thu, 8 Jul 2021 09:34:41 +0200 (CEST) Received: from localhost ([::1]:36962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1OYS-0004a3-HN for larch@yhetil.org; Thu, 08 Jul 2021 03:34:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1OXl-0004Zr-BY for emacs-orgmode@gnu.org; Thu, 08 Jul 2021 03:33:57 -0400 Received: from relay-egress-host.us-east-2.a.mail.umich.edu ([18.216.144.57]:49696 helo=dry-hafgan.relay-egress.a.mail.umich.edu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m1OXj-0002kU-KZ for emacs-orgmode@gnu.org; Thu, 08 Jul 2021 03:33:57 -0400 Received: from antic-ogre.authn-relay.a.mail.umich.edu (ip-10-0-74-13.us-east-2.compute.internal [10.0.74.13]) by dry-hafgan.relay-egress.a.mail.umich.edu with ESMTPS id 60E6AA5E.ECA05.2416CB56.1750005; Thu, 08 Jul 2021 03:33:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umich.edu; s=relay-2018-08-29; t=1625729630; bh=6VZKXm7d+zbB7+fWW2xRuAaZNGinWyhzFi1hP0Hhtuc=; h=From:To:cc:Subject:In-reply-to:Date; b=QKzeEJNqQoxyMNfI0dsg6e1fUqUINh8yPnZQKRtqKTcar1Hrv/WgTasYB0DoWGZHC +n/DqrYoLGS6quSZBUg5nnIZycmZjq6rmbvKICtm3A3SgafzQrCDlsaQ6huRAk9KyK DMNqc23G5jAwjNHydQ/mBbI0kZgM8OviGwogAVgJD/mQ0nzBc1nP3DYfDz4I42ZcLb wlAAoPm6uzA+Go2sVdUmU+FOxb4EYUXusglTCtabhpl+vY8kKBUMtRxf4RUVJjBtf9 zJtKcwfgPuN17LUw+qf+4QW+56l5vpklulU6GV2ogDTostUbTzCCMnJYicx5rweYU+ 6dmAAMTbwtx4Q== Received: from localhost (Mismatch [95.14.94.108]) by antic-ogre.authn-relay.a.mail.umich.edu with ESMTPSA id 60E6AA5D.7F734.446B0CC2.2063841; Thu, 08 Jul 2021 03:33:50 -0400 From: Greg Minshall To: Uwe Brauer Subject: Re: [R example for org-table with ifs] In-reply-to: Your message of "Thu, 08 Jul 2021 08:26:24 +0200." <87a6mxwcbz.fsf@mat.ucm.es> X-Mailer: MH-E 8.6+git; nmh 1.7.1; GNU Emacs 27.2 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <552665.1625729625.1@apollo2.minshall.org> Date: Thu, 08 Jul 2021 10:33:45 +0300 Message-ID: <552666.1625729625@apollo2.minshall.org> Received-SPF: pass client-ip=18.216.144.57; envelope-from=minshall@umich.edu; helo=dry-hafgan.relay-egress.a.mail.umich.edu 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, 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: emacs-orgmode@gnu.org 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=1625729682; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=6VZKXm7d+zbB7+fWW2xRuAaZNGinWyhzFi1hP0Hhtuc=; b=GoU7xxXxc5Za3sMywXU64gTAPAT+8jULaz03vhZbzdg3svoYhufEobUk2wuYGkt/9dW4dZ I7SQnkZb3QP+/P1SsxC0t/C+tfVuSXCI06h07RkSKtl5mGQ4+KfsOmh7UrwBR2QQmv0U2M gQWj8jS44iuCbWVYTyoI6T1E7Hp3uFet8w1DxF7U3IyWkiYy4Q5t8j9mhf4FbpI4zfqrxU 47QOJiHgl1isRiqsydOPr16uvth2PSNSNi0e3KcWTKigkbRm2Hf9YKk9zMnwMVhyUdrXgK Li8J+iV20KuthAXX6EflvF2ucU86tHlyVYkBc40r8CXjoygvWlDRDue0aHftZg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625729682; a=rsa-sha256; cv=none; b=R20OyoXsGoYSFRsDCbQzbf7JnRjkZS5A2LdVaLyjyiiT0V4TXbg9Nh24bzXLDUkrxzIM1C f+NpoRDIUtaJtvNV3R0CKSpSxk9lgaCDHnSXwFF6ZQ9AWkLuB5e/aSnSf0mlUif9j+L0Ve p3T+yOYbf7jCJi22nQJ64vVCmjfsVKQr7+eMFfJiLNWvJQLai6Yb5ra1ty0Vn+ZM8jzrh/ nDztRUoOYWrVAoA6nh9cdDV9uSfs9Nkq7d0fWub9HLMorac3log9+wgLiZPiVn9JzBC5UF KK18hw//qTLbnudIFBfdIvlIittXev7/+HOm4bWhRWv3lmM4IVOZqO8M/HJ5sw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=umich.edu header.s=relay-2018-08-29 header.b=QKzeEJNq; dmarc=pass (policy=none) header.from=umich.edu; 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: -3.11 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=umich.edu header.s=relay-2018-08-29 header.b=QKzeEJNq; dmarc=pass (policy=none) header.from=umich.edu; 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: 71F0024949 X-Spam-Score: -3.11 X-Migadu-Scanner: scn1.migadu.com X-TUID: /esxpM0lZF8c Uwe, > Thanks but I have to disappoint you the correct result should be 10.1 ah, well. :) i realized you probably wanted the table back. below it is, with your explanation of "@3$3". > Thanks I will play around a bit, but for the moment I think I have to > stick with calc well, takes all kinds. :) cheers, Gerg ---- #+begin_src R :var some=thing :session R :colnames yes ## in imported colnames, spaces are replaced with periods some[, "Result"] <- ifelse(some[, "DMNI.H"] > 10, (some[, "DMNI.H"] - 10.0) * (some[X == "Weight:", "Weight2"]), 0.0) + (min(10, some[, "DMNI.H"]) * some[X == "Weight:", "ExNDM.I"]) + (ifelse(some[, "ExNDNM.J"] > 10, some[, "ExNDNM.J"] - 10 * some[X == "Weight:", "DMNI.H"], 0)) + (min(10, some[, "ExNDNM.J"]) * some[X == "Weight:", "ExNDNM.J"]) + (some[X == "Weight:", "Result"] * some[, "Result"]) some #+end_src #+RESULTS: | X | DMI.G | DMNI.H | ExNDM.I | ExNDNM.J | Result | Weight2 | |---------+-------+--------+---------+----------+--------+---------| | Weight: | 1 | 0.2 | 1 | 0.1 | | 0.1 | | User1 | 0 | 0 | 11 | 0 | 10.1 | |