> On Apr 19, 2024, at 1:36?PM, CRAN.r via R-help <r-help at
r-project.org> wrote:
>
> Is there a way to pass a modified argument from an S3 generic to a method?
Here's a non-working example that I want to return "abcd".
>
grep-ing the source code is often a good way to answer a question like this.
Particularly, with NextMethod there seem to be plenty of instances in which the
original arguments are modified before a call to a method.
One such is `t.data.frame` and there seem to be other methods for
"data.frame" objects that modify the objects before calling
NextMethod.
HTH,
Chuck
> test <- function(x, y = NULL){
> y <- "abcd"
> UseMethod("test")
> }
> test.default <- function(x, y = NULL) y
> test(x = 3)
>
> Is that possible? I've looked around a lot, but can't find any
examples or discussion.
>
> Jay
>
> From nobody Sat Apr 20 10:07:59 2024
> Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
> From: "CRAN.r via R-help" <r-help at r-project.org>
> Newsgroups: gmane.comp.lang.r.general
> Subject: passing a modified argument to an S3 method
> Date: Fri, 19 Apr 2024 20:36:22 +0000
> Approved: news at gmane.org
> Message-ID:
<4pRzEDv__NGDIT68Q6LBK0OcyD9iQs3g6SkZemots3x4noMUQIV8UAfjDEe2UOq6-D4FF6z0T-76bUG0UxqFccqyFKVKw31OB_Iyh0kbzFs=@proton.me>
> Reply-To: "CRAN.r" <cran.r at proton.me>
> Mime-Version: 1.0
> Content-Type: text/plain; charset="us-ascii"
> Content-Transfer-Encoding: 7bit
> Injection-Info: ciao.gmane.io;
posting-host="blaine.gmane.org:116.202.254.214";
> logging-data="8351"; mail-complaints-to="usenet at
ciao.gmane.io"
> To: "r-help at r-project.org" <r-help at r-project.org>
> Original-X-From: r-help-bounces at r-project.org Sat Apr 20 13:23:27 2024
> Return-path: <r-help-bounces at r-project.org>
> Envelope-to: gclrg-r-help at m.gmane-mx.org
> Original-Received: from hypatia.math.ethz.ch ([129.132.119.208])
> by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
> (Exim 4.92)
> (envelope-from <r-help-bounces at r-project.org>)
> id 1ry8oY-0001sq-Bn
> for gclrg-r-help at m.gmane-mx.org; Sat, 20 Apr 2024 13:23:26 +0200
> Original-Received: from localhost (localhost [127.0.0.1])
> by hypatia.math.ethz.ch (Postfix) with ESMTP id 439F319B4;
> Sat, 20 Apr 2024 13:23:25 +0200 (CEST)
> Authentication-Results: hypatia.math.ethz.ch (amavisd-new);
> dkim=pass (1024-bit key) reason="pass (just generated, assumed
good)"
> header.d=r-project.org
> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=r-project.org; h>
content-transfer-encoding:content-type:content-type:reply-to
> :from:from:list-subscribe:list-help:list-post:list-archive
> :list-unsubscribe:list-id:precedence:subject:subject
> :mime-version:message-id:date:date:received:received:received
> :received:received:received; s=dkim20211220; t=1713612201; x>
1716204202; bh=Z6v15ZPk1rn+11Ef9rNBtKr6kCXFKaj/SGL/HXarBWc=; b=H
> O9aWKsrJKBwRK33ySDQjcif0WL28cjIvg6O3iIC0c1aB+fihnMC/BTLjCyUGIorY
> Yx7Um4sp4+sw0nnmvWWBKL1e1YVr5+QfUCkIyDU6NawYEeC8m3VjEQa7KMALgJN5
> awIR6NsAbCK1ewPN2QPNWMxpIftLzbaQOWMWPCqOPU> X-Virus-Scanned: amavisd-new
at r-project.org
> Original-Received: from hypatia.math.ethz.ch ([127.0.0.1])
> by localhost (hypatia.math.ethz.ch [127.0.0.1]) (amavisd-new, port 10024)
> with LMTP id O5euluMcNO0X; Sat, 20 Apr 2024 13:23:21 +0200 (CEST)
> Original-Received: from hypatia.math.ethz.ch (localhost [127.0.0.1])
> by hypatia.math.ethz.ch (Postfix) with ESMTP id 8C1D44D3;
> Sat, 20 Apr 2024 13:23:21 +0200 (CEST)
> Original-Received: from localhost (localhost [127.0.0.1])
> by hypatia.math.ethz.ch (Postfix) with ESMTP id 1378F1C23
> for <r-help at r-project.org>; Fri, 19 Apr 2024 22:36:39 +0200 (CEST)
> X-Virus-Scanned: amavisd-new at r-project.org
> Original-Received: from hypatia.math.ethz.ch ([127.0.0.1])
> by localhost (hypatia.math.ethz.ch [127.0.0.1]) (amavisd-new, port 10024)
> with LMTP id y-CERIWOjFBy for <r-help at r-project.org>;
> Fri, 19 Apr 2024 22:36:34 +0200 (CEST)
> Original-Received: from ethz.ch (mc3.ethz.ch [129.132.198.195])
> (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
> (No client certificate requested)
> by hypatia.math.ethz.ch (Postfix) with ESMTPS id 87F5E1B8C
> for <r-help at r-project.org>; Fri, 19 Apr 2024 22:36:34 +0200 (CEST)
> Original-Received: from mail-4322.protonmail.ch ([185.70.43.22])
> by ethz.ch stage1 with esmtps (Exim MailCleaner)
> id 1rxv0v-000253-1n for <r-help at r-project.org>
> from <cran.r at proton.me>; Fri, 19 Apr 2024 22:39:17 +0200
> X-MailCleaner-SPF: pass
> Feedback-ID: 100000121:user:proton
> X-Pm-Message-ID: 1d72f1b23cf9e2d0142aaa1edb9ef8ebccac926b
> X-Newsl: is not newsletter (0.0/5.0) position : 0, not decisive
> X-NiceBayes: is not spam (52.38%) position : 3, not decisive
> X-Spamc: is not spam (0.0/5.0) position : 7, ham decisive
> X-MailCleaner-Information: Please contact servicedesk at id.ethz.ch for
more
> information
> X-MailCleaner-ID: 1rxv0v-000257-24
> X-MailCleaner: Found to be clean
> X-MailCleaner-SpamCheck: not spam, Newsl (score=0.0, required=5.0, NONE,
> position : 0, not decisive), NiceBayes (52.38%, position : 3,
> not decisive), Spamc (score=0.0, required=5.0,
> RCVD_IN_MSPIKE_H4 -0.0, DKIM_VALID -0.3, RCVD_IN_MSPIKE_WL -0.0,
> MC_SPF_PASS -0.0, BOTNET_IPINHOSTNAME 1.0,
> MC_DKIM_OK_NO_FREEMAIL -1.0, DKIM_VALID_AU -0.3, DKIM_SIGNED 0.6,
> position : 7, ham decisive)
> X-MailCleaner-ReportURL: https://mailcleaner.ethz.ch/rs.php
> X-Mailman-Approved-At: Sat, 20 Apr 2024 13:23:20 +0200
> X-BeenThere: r-help at r-project.org
> X-Mailman-Version: 2.1.25+j1
> Precedence: list
> List-Id: "Main R Mailing List: Primary help"
<r-help.r-project.org>
> List-Unsubscribe: <https://stat.ethz.ch/mailman/options/r-help>,
> <mailto:r-help-request at r-project.org?subject=unsubscribe>
> List-Archive: <https://stat.ethz.ch/pipermail/r-help/>
> List-Post: <mailto:r-help at r-project.org>
> List-Help: <mailto:r-help-request at r-project.org?subject=help>
> List-Subscribe: <https://stat.ethz.ch/mailman/listinfo/r-help>,
> <mailto:r-help-request at r-project.org?subject=subscribe>
> Errors-To: r-help-bounces at r-project.org
> Original-Sender: "R-help" <r-help-bounces at r-project.org>
> Xref: news.gmane.io gmane.comp.lang.r.general:365491
> Archived-At:
<http://permalink.gmane.org/gmane.comp.lang.r.general/365491>
>
> Is there a way to pass a modified argument from an S3 generic to a method?
Here's a non-working example that I want to return "abcd".
>
> test <- function(x, y = NULL){
> y <- "abcd"
> UseMethod("test")
> }
> test.default <- function(x, y = NULL) y
> test(x = 3)
>
> Is that possible? I've looked around a lot, but can't find any
examples or discussion.
>
> Jay
>