Displaying 20 results from an estimated 20000 matches similar to: "Extracting specific arguments from "...""
2025 Jan 07
2
Extracting specific arguments from "..."
Colleagues,
My interest is not in writing ad hoc functions (which I might use once to analyze my data), but rather what I will call a system function that might be part of a package. The lm function is a paradigm of what I call a system function.
The lm function begins by processing the arguments passed to the function (represented in the function as parameters, see code below.) Much of this
2025 Jan 07
1
Extracting specific arguments from "..."
There's an ancient (2003) document on the CRAN "developers' page"
https://developer.r-project.org/model-fitting-functions.html that is
sort of (but not exactly) what you're looking for ...
On 2025-01-07 5:03 p.m., Sorkin, John wrote:
> Colleagues,
>
> My interest is not in writing ad hoc functions (which I might use once to analyze my data), but rather what I
2025 Jan 07
1
Extracting specific arguments from "..."
Ben,
As always, thank you.
You are correct, it is something like what I want, but not exactly. Perhaps someday someone will write a more complete guide.
Thank you,
John
John David Sorkin M.D., Ph.D.
Professor of Medicine, University of Maryland School of Medicine;
Associate Director for Biostatistics and Informatics, Baltimore VA Medical Center Geriatrics Research, Education, and Clinical
2023 Mar 16
4
Trying to learn how to write an "advanced" function
I am trying to understand how to write an "advanced" function. To do so, I am examining the lm fucnction, a portion of which is pasted below. I am unable to understand what match.call or match does, and several other parts of lm, even when I read the help page for match.call or match.
(1) can someone point me to an explanation of match.call or match that can be understood by the
2025 Jan 06
2
Extracting specific arguments from "..."
Bert and other on this Chain,
The original question asked by Bert Gunter, highlights one of my long standing wishes. Perhaps my wish has already been fulfilled (if it has, please let me know where I can look of fulfill my wish), if it hasn't perhaps someone can grant me my wish.
I have tried to understand how to write a function (beyond a basic function), get values of the parameters, and
2025 Jan 07
1
Extracting specific arguments from "..."
It is a pretty tricky topic, but IMO Advanced R [1] steps you through it systematically... you just have to be prepared to follow along in R with the examples as you read it. In particular, the chapter on Functions goes through this.
The subtleties of how base R gives you control over these topics is what lead to the tidyverse creating new packages to build such function interfaces. Manipulating
2025 Jan 06
1
Extracting specific arguments from "..."
Thanks Jorgen.
I thought your approach to getting the argument expressions was clever, but
somewhat convoluted. I think the usual simple way is to use match.call()
(or sys.call() )to get the unevaluated argument expressions; e.g. ...
f <- function(...){
match.call()
}
> f(a = 'red', b = sin(zzz))
f(a = "red", b = sin(zzz))
The return value is an object of class call
2025 Jan 07
1
Extracting specific arguments from "..."
Jeff:
Would you care to offer an example of:
"String literals are surprisingly simple alternatives that don't bite you
in the butt nearly so often as NSE does."
"No" is a perfectly acceptable answer.
I would generally agree with you about NSE, but my original query was
motivated by something simple. I like to use lattice graphics when I fool
around with graphing data, as
2025 Jan 06
1
Extracting specific arguments from "..."
I think Bert Gunter is right, but do you want partial matches (not found by match), and how robust do you want the code to be?
f <- function(?)
{ pos <- match('a', ...names())
if (is.na(pos))
stop("a is required.")
?elt(pos)
}
Incidentally, what is the best way to extract the expression without evaluating it?
g <- function(...)
{ pos <-
2013 Jan 29
3
how to suppress the intercept in an lm()-like formula method?
I'm trying to write a formula method for canonical correlation analysis,
that could be called similarly to lm() for
a multivariate response:
cancor(cbind(y1,y2,y3) ~ x1+x2+x3+x4, data=, ...)
or perhaps more naturally,
cancor(cbind(y1,y2,y3) ~ cbind(x1,x2,x3,x4), data=, ...)
I've adapted the code from lm() to my case, but in this situation, it
doesn't make sense to
include an
2001 Dec 17
1
environments again
In a previous message I was not clear enough in my querry.
I have the following program:
tst<- function() {
x <- c(32.7,32.3,31.5,32.1,29.7,29.1,35.7,35.9,33.1,
36.0,34.2,31.2,31.8,28.0,29.2,38.2,37.8,31.9,
32.5,31.1,29.7)
g <- rep(1:7,rep(3,7))
s <- rep(1:3,7)
cat(" Only x and g \n")
aov1(x,g)
cat("\n\n Now x, g and s \n")
aov1(x,g,s=s)
}
2016 Apr 20
6
Solving sparse, singular systems of equations
I have a situation in R where I would like to find any x (if one exists) that solves the linear system of equations Ax = b, where A is square, sparse, and singular, and b is a vector. Here is some code that mimics my issue with a relatively simple A and b, along with three other methods of solving this system that I found online, two of which give me an error and one of which succeeds on the
2008 Feb 19
1
Matrix inversion
Howdy,
I am trying to invert a matrix for the purposes of least squares. I
have tried a number of things, and the variety of results has me
confused.
1. When I try solve() I get the following:
>Error in solve.default(t(X) %*% X) : system is computationally
singular: reciprocal condition number = 3.76391e-20
2. When I try qr.solve(), I get:
>Error in qr.solve(t(X) %*% X) : singular matrix
2023 Nov 03
1
[EXTERNAL] RE: I need to create new variables based on two numeric variables and one dichotomize conditional category variables.
Yes, that will halve the number of multiplications.
If you?re looking for such optimisations then you can also consider ifelse(G=='male', 65L, 58L). That will definitely use less time & memory if WC is integer, but the trade-offs are more complicated if WC is floating point.
Regards,
Jorgen Harmse.
From: avi.e.gross at gmail.com <avi.e.gross at gmail.com>
Date: Friday,
2002 Jun 26
3
Bug or failing understanding?
Hola!
I seem to remember i used to have the same name of argument and default
value in argument list to functions, but (rw1.5.1) this seems not to
work:
> x <- 3
> test <- function(x=x) x*x
> test(7)
[1] 49
> test()
Error in test() : recursive default argument reference
here is a code fragment from lm() using the same syntax:
else {
x <- model.matrix(mt, mf,
2023 Nov 03
2
I need to create new variables based on two numeric variables and one dichotomize conditional category variables.
Just a minor point in the suggested solution:
df$LAP <- with(df, ifelse(G=='male', (WC-65)*TG, (WC-58)*TG))
since WC and TG are not conditional, would this be a slight improvement?
df$LAP <- with(df, TG*(WC - ifelse(G=='male', 65, 58)))
-----Original Message-----
From: R-help <r-help-bounces at r-project.org> On Behalf Of Jorgen Harmse via
R-help
Sent: Friday,
2010 Oct 31
1
biglm: how it handles large data set?
I am trying to figure out why 'biglm' can handle large data set...
According to the R document - "biglm creates a linear model object that uses
only p^2 memory for p variables. It can be updated with more data using
update. This allows linear regression on data sets larger than memory."
After reading the source code below? I still could not figure out how
'update'
2011 Apr 19
1
How to Extract Information from SIMEX Output
Below is a SIMEX object that was generated with the "simex" function from the
"simex" package applied to a logistic regression fit. From this mountain of
information I would like to extract all of the values summarized in this
line:
.. ..$ variance.jackknife: num [1:5, 1:4] 1.684 1.144 0.85 0.624 0.519 ...
Can someone suggest how to go about doing this? I can extract the
2009 Jun 28
1
ERROR: system is computationally singular: reciprocal condition number = 4.90109e-18
Hi All,
This is my R-version information:---
> version
_
platform i486-pc-linux-gnu
arch i486
os linux-gnu
system i486, linux-gnu
status
major 2
minor 7.1
year 2008
month 06
day 23
svn rev 45970
language R
version.string R version 2.7.1 (2008-06-23)
While calculating partial
2007 Jan 06
2
negative binomial family glm R and STATA
Dear Lister,
I am facing a strange problem fitting a GLM of the negative binomial
family. Actually, I tried to estimate theta (the scale parameter)
through glm.nb from MASS and could get convergence only relaxing the
convergence tolerance to 1e-3. With warning messages:
glm1<-glm.nb(nbcas~.,data=zonesdb4,control=glm.control(epsilon = 1e-3))
There were 25 warnings (use warnings() to see