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 aP56HpmJ5mAEOgEAgWs5BA (envelope-from ) for ; Thu, 08 Jul 2021 07:14:01 +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 wA0YGpmJ5mDpDgAAbx9fmQ (envelope-from ) for ; Thu, 08 Jul 2021 05:14:01 +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 6CF9A23040 for ; Thu, 8 Jul 2021 07:14:00 +0200 (CEST) Received: from localhost ([::1]:34254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1MMI-0003PU-7H for larch@yhetil.org; Thu, 08 Jul 2021 01:13:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1MLw-0003Nx-BU for emacs-orgmode@gnu.org; Thu, 08 Jul 2021 01:13:36 -0400 Received: from relay-egress-host.us-east-2.a.mail.umich.edu ([18.217.159.240]:41012 helo=sound-pryderi.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 1m1MLu-0001UH-92 for emacs-orgmode@gnu.org; Thu, 08 Jul 2021 01:13:36 -0400 Received: from cobalt-duende.authn-relay.a.mail.umich.edu (ip-10-0-73-213.us-east-2.compute.internal [10.0.73.213]) by sound-pryderi.relay-egress.a.mail.umich.edu with ESMTPS id 60E6897D.A314.4359E33F.3950190; Thu, 08 Jul 2021 01:13:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umich.edu; s=relay-2018-08-29; t=1625721212; bh=3rUn5D3g6KQwQZZeATRLSveiVUUL8q78I1FZZGy07QA=; h=From:To:cc:Subject:In-reply-to:Date; b=ivVvnalb+JbfbUmUlWgYRzM8Vi3Jh+gNlrUxhClKyuaGvsqEJf7gRHQbVVLMB/lPo 543IKgNT01qw59fFPLzqb5Vlh1MFLbsLi54+cfFldcWFEN3wduoR6Zh1h4W8ngja2l 9MQPf7PhCs3i3jd8emNzGpqJkh+0Oq3NFr3OAxbtCROHlYjP2iZoNMDJn+99RYamlr UkvP2R1TumGEBbgT2ouj4E8a6uQhbDV/MBQNTFm1zzIJkIJ4ZJspNZ2d5KyttnZdog kLW/XtMxuy5idMFHjKhNhpCvwEuRtauhWgk9aIasBxbLTe7YENPuTOxmVrSUH+XMNg rNGSt6vdggSRQ== Received: from localhost (Mismatch [95.14.94.108]) by cobalt-duende.authn-relay.a.mail.umich.edu with ESMTPSA id 60E6897B.8AEB5.734E6AF7.60648; Thu, 08 Jul 2021 01:13:32 -0400 From: Greg Minshall To: Uwe Brauer Subject: Re: [R example for org-table with ifs] (was: [External] : Re: export org table to other formats (gnumeric or scalc or xlsx)) In-reply-to: Your message of "Wed, 07 Jul 2021 09:01:47 +0200." <87k0m2zjxg.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: <532196.1625721207.1@apollo2.minshall.org> Content-Transfer-Encoding: quoted-printable Date: Thu, 08 Jul 2021 08:13:27 +0300 Message-ID: <532197.1625721207@apollo2.minshall.org> Received-SPF: pass client-ip=18.217.159.240; envelope-from=minshall@umich.edu; helo=sound-pryderi.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=1625721241; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=3rUn5D3g6KQwQZZeATRLSveiVUUL8q78I1FZZGy07QA=; b=H7MXk5fYOjOFClH71EM3ZOavxZmzLKyJaaOd/w6seF1zQYS2EICi2d/hkVQ1xL1x+CwYGO jFSH1rMA3yojCoGXTG9Y4ugd7gOpAJlBFExcdyDYpeYulHB3LBiGDDgYc67J/KIM56XXRn ggjPII02ej8XTmEAV/irMtOapCWva7C2jzWSxrS0ptyLRjGFtSC5QHB6ZfTVJBtLUtStLD tjgTVMFHGkQtgQ0Ao6ac0DIeMAHQfrfQ+U/5luDto8CyYizXoq8vvxYH66RFWsXIbfc/hm VvXlwbXNvMP6PZmPJ8YWSm/Kbg6CPXEHJBo1wBra0yhq07qpWqGGiAEQGUhrbg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625721241; a=rsa-sha256; cv=none; b=ss1MMKGAeatki+SJGO0smckNtuapkydRJOE/GttAs+Jy0ZIb4HGzzRCJEndEhMVMGyPfZX wDU7ooxVMemtDnsC4Lc0l1WHj5IKgLIu7UGRmv1kjmdENrXQPF/dsbUKd0Q5AY4hRpEcgL q5lMuZOAHIXRyCpDALx5jVJXsdCY9rsG5z2m/LgMpdPpVxxKb6XSXxZY54S+AINMBhRnSD As7t2499dRLJHPkUmgfS2ZZGnFk+OhNTFeOt6xsxjzWt6uuiObnizGkn5XKek7V2RRR/l7 pBliiNDXNEUJQ2YtXPh6tOQwTOyFS93TAAUU8exHPCMzanHKb0Ce65d+f2pTwA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=umich.edu header.s=relay-2018-08-29 header.b=ivVvnalb; 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=ivVvnalb; 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: 6CF9A23040 X-Spam-Score: -3.11 X-Migadu-Scanner: scn1.migadu.com X-TUID: lpPqsJ302itn Uwe, well, *i* no longer remember how to read calc-like expressions. and, i'm a notoriously poor R coders. assuredly the following is not doing what you want, but possibly you'll get the idea. (if 102.01 is, indeed, the correct answer, feel free to buy me a hot fudge sundae some day. :) cheers, Greg #+name: thing | / | <> | <> | <> | <> | <> | <> | <> | | | | 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 | | |---+---------+-------+--------+---------+----------+--------+---------| #+TBLFM: $7=3Dif($3>10,($3-10)*@3$8,0)+ min(10,$3)*@3$3+ min(10,$4)*@3$4 += if($5>10,($5-10)*@3$8,0)+min(10,$5)*@3$5 +@3$6*$6;f1:: - does "@3$3" mean the third column in the third row? - is that the "DMNI H" column? - is that the "User1" row? i replace "@3" with the last row of the input table. #+begin_src R :var some=3Dthing :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[nrow(some), "Weight= 2"]), 0.0) + (min(10, some[, "DMNI.H"]) * some[nrow(some), "ExNDM.I"]) + (ifelse(some[, "ExNDNM.J"] > 10, some[, "ExNDNM.J"] - 10 * some[nrow(s= ome), "DMNI.H"], 0)) + (min(10, some[, "ExNDNM.J"]) * some[nrow(some), "ExNDNM.J"]) + (some[nrow(some), "Result"] * some[, "Result"]) #+end_src #+RESULTS: | x | |--------| | | | 102.01 |