Displaying 20 results from an estimated 10000 matches similar to: "splitting up optional args"
2007 Apr 16
1
args / formals on primitives
On SVN revision 41087:
?args has this example line:
args(c) # -> NULL (c is a 'primitive' function)
The comment seems out of date, as args(c) does in fact have a non-NULL return
value:
args(c)
# function (..., recursive = FALSE)
# NULL
While at it, I was wondering, why
formals(c)
still returns NULL, in contrast.
Regards
Thomas Friedrichsmeier
-------------- next
2018 May 03
1
The stages of standard function evaluation
Dear R Help folks --
I have been trying to put together a list of the steps or stages of R
function evaluation, with particular focus on those that have "standard" or
"nonstandard" forms. This is both for my own edification and also because I
am thinking of joining the world of R bloggers and have been trying to put
together some draft posting that might be useful. I seem to
2017 Jan 31
1
rnbinom Returns Error that says optional argument is missing
I am trying to reset the default arguments in the rnbinom function with the
following example code:
params <- c("size" = 1, "mu" = 1)
formals(rnbinom)[names(params)] <- params
rnbinom(n = 10)
It returns the following:
Error in rnbinom(n = 10) : argument "prob" is missing, with no default
If I set the defaults with this code:
params <- c("size"
2024 Feb 18
1
Capturing Function Arguments
? Sat, 17 Feb 2024 11:15:43 -0700
"Reed A. Cartwright" <racartwright at gmail.com> ?????:
> I'm wrapping a function in R and I want to record all the arguments
> passed to it, including default values and missing values.
This is hard if not impossible to implement for the general case
because the default arguments are evaluated in the environment of the
function as it
2009 Mar 23
2
dput(as.list(function...)...) bug
Tested in R 2.8.1 Windows
> ff <- formals(function(x)1)
> ff1 <- as.list(function(x)1)[1]
# ff1 acts the same as ff in the examples below, but is a list rather
than a pairlist
> dput( ff , control=c("warnIncomplete"))
list(x = )
This string is not parsable, but dput does not give a warning as specified.
> dput( ff ,
2010 Apr 04
2
logistic regression in an incomplete dataset
Dear all,
I want to do a logistic regression.
So far I've only found out how, in a dataset of complete cases.
I'd like to do logistic regression via max likelihood, using all the study
cases (complete and incomplete). Can you help?
I'm using glm() with family=binomial(logit).
If any covariate in a study case is missing then the study case is
dropped, i.e. it is doing a complete case
2010 May 23
2
possible bug in formals
Hi,
I am a little bit surprised by the following output of
'formals'. Is this the intended behavior?
> f <- function(a=1,b=-1) { a+b }
> class(formals(f)$a)
[1] "numeric"
> class(formals(f)$b)
[1] "call"
Josef
--
-----------------------------------------------------------------------------
Josef Leydold | WU (Vienna University of Economics and
2011 Feb 18
3
lm without intercept
Hi,
I am not a statistics expert, so I have this question. A linear model
gives me the following summary:
Call:
lm(formula = N ~ N_alt)
Residuals:
Min 1Q Median 3Q Max
-110.30 -35.80 -22.77 38.07 122.76
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 13.5177 229.0764 0.059 0.9535
N_alt 0.2832 0.1501 1.886 0.0739
2010 Oct 08
2
What do you call the value that represents a missing argument?
Hi all,
What's the official name for the value that represents a missing argument?
e.g.
formals(plot)$x
str(formals(plot)$x)
deparse(formals(plot)$x)
is.symbol(formals(plot)$x)
What's the correct way to create an object like this? (for example if
you are manipulating the formals of a function to add an argument with
no default value, as in http://stackoverflow.com/questions/3892580/).
2009 Jul 24
1
Most elegant way to use formals() in building functions
Dear Group:
I want to create a function having a ... argument and to have the
default arguments evaluated, as thus:
g <- function(a, b, ...) a+b
formals(g) <- alist(a=,b=2+3,...=)
g
function (a, b = 2 + 3, ...)
a + b
But I want the default argument for b to be evaluated as 5. How can
this be done? Note: My real need is for a more complex expression to be
evaluated for the default
2008 Nov 21
1
Wishlist: fix error in documentation for body<- (PR#13318)
Full_Name: Fabian Scheipl
Version: 2.8.0
OS: Windows, Linux
Submission from: (NULL) (138.246.7.150)
It seems to me that the documentation for body<- is wrong.
The help file for
body(fun, envir = environment(fun)) <- value
says that:
value can be an expression or a list of R expressions.
This produces errors however:
################################
> f <- function(x){}
>
2011 Aug 01
1
Impact of multiple imputation on correlations
Dear all,
I have been attempting to use multiple imputation (MI) to handle missing data in my study. I use the mice package in R for this. The deeper I get into this process, the more I realize I first need to understand some basic concepts which I hope you can help me with.
For example, let us consider two arbitrary variables in my study that have the following missingness pattern:
Variable 1
2017 Dec 19
1
lm considers removed predictors when finding complete cases
Dear R-devel list,
I realized that removing a predictor in lm through the "-"'s operator in
formula() does not affect the complete cases that are considered. A minimal
example is:
summary(lm(Wind ~ ., data = airquality))
# 42 observations deleted due to missingness
summary(lm(Wind ~ . - Ozone, data = airquality))
# still 42 observations deleted due to missingness, even if only 7
2012 Oct 02
2
Problem with mutli-dimensional array
I want to make a multi-dimensional array. To be specific I want to make the
following array
results<-array(0,dim=c(2,2,64,7))
This is the code I have created but it gives no result due to the error
"subscript out of bound".
x<-rep(7,7) # Missingness in intervention
y<-rep(7,7) # Missingness in control
2007 Jun 15
2
method of rpart when response variable is binary?
Dear all,
I would like to model the relationship between y and x. y is binary
variable, and x is a count variable which may be possion-distribution.
I think it is better to divide x into intervals and change it to a
factor before calling glm(y~x,data=dat,family=binomail).
I try to use rpart. As y is binary, I use "class" method and get the
following result.
>
2008 Aug 01
1
importing explicitly declared missing values in read.spss (foreign)
There is a problem when importing an spss-file containing explicitly declared
missing values in R using the read.spss function from the foreign package.
I'm not sure these problems are the same in every version of spss, I am
using the latest version 16.0.2.
I included http://www.nabble.com/file/p18776776/missingdata.sav
missingdata.sav and
2013 May 16
3
Substitute / delayedAssign (was: Substitute unaware when promise objects are evaluated)
Duncan, Thank you for the clarification on how delayedAssign works. Should R-level interfaces to promise objects ever become available, I expect they would at time come in handy.
On the subject of substitute and delayedAssign, I do have a follow-up question for the list. I'm trying to convert a named list of expression objects into an environment of promise objects. After conversion, each
2002 May 02
0
improving match.args()
Here is a suggestion for improving match.arg()
Comments welcome.
Best
Jens Oehlschl?gel
# up to now match.arg() works as
t1 <- function( param = c("default", "alternative1", "alternative2") ){
param <- match.arg(param)
param
}
# and
args(t1)
# > function (param = c("default", "alternative1", "alternative2"))
#
2018 Oct 06
1
Warning when calling formals() for `[`.
Hi,
Thanks for the note. How would explain the following snippet taken from
`formals` doc page (the code comment is also from that doc) ?
## formals returns NULL for primitive functions. Use it in combination with
## args for this case.
is.primitive(`+`)
formals(`+`)
formals(args(`+`))
Le sam. 6 oct. 2018 ? 13:42, Rui Barradas <ruipbarradas at sapo.pt> a ?crit :
2000 Aug 21
4
symbols: xlim and ylim cannot be specified (PR#639)
symbols(iris[,1],iris[,2],rectangles=as.matrix(iris[,3:4]),inches=0.3,
ylim=c(1,5))
Error in plot.default(NA, NA, type = "n", ylim = ylim, xlim = xlim, xlab = xlab, :
formal argument "ylim" matched by multiple actual arguments
Since plot is called inside symbols, with specified xlim and ylim,
any specification through ,... hurts this call.
I am pretty sure that you