Displaying 20 results from an estimated 4000 matches similar to: "R-intro: function 'stderr' and 'sd'"
2016 Sep 13
1
R-intro: function 'stderr' and 'sd'
While you are editing that, you might change its name from 'stderr'
to standardError (or standard_error, etc.) so as not to conflict with
base::stderr().
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Sep 13, 2016 at 8:55 AM, Martin Maechler <maechler at stat.math.ethz.ch
> wrote:
> >>>>> Suharto Anggono Suharto Anggono via R-devel <r-devel at
2016 Aug 11
2
table(exclude = NULL) always includes NA
I stand corrected. The part "If set to 'NULL', it implies 'useNA="always"'." is even in the documentation in R 2.8.0. It was my fault not to check carefully.
I wonder, why "always" was chosen for 'useNA' for exclude = NULL.
Why exclude = NULL is so special? What about another 'exclude' of length zero, like character(0) (not c(),
2016 Aug 07
2
table(exclude = NULL) always includes NA
This is an example from https://stat.ethz.ch/pipermail/r-help/2007-May/132573.html .
With R 2.7.2:
> a <- c(1, 1, 2, 2, NA, 3); b <- c(2, 1, 1, 1, 1, 1)
> table(a, b, exclude = NULL)
b
a 1 2
1 1 1
2 2 0
3 1 0
<NA> 1 0
With R 3.3.1:
> a <- c(1, 1, 2, 2, NA, 3); b <- c(2, 1, 1, 1, 1, 1)
> table(a, b, exclude = NULL)
b
a 1 2
2016 Sep 26
2
Undocumented 'use.names' argument to c()
By "an argument named 'use.names' is included for concatenation", I meant something like this, that someone might try.
> c(as.Date("2016-01-01"), use.names=FALSE)
use.names
"2016-01-01" "1970-01-01"
See, 'use.names' is in the output. That's precisely because 'c.Date' doesn't have 'use.names', so
2016 Aug 27
2
'droplevels' inappropriate change
In R devel r71157, 'droplevels' documentation, in "Arguments" section, says this about argument 'exclude'.
passed to factor(); factor levels which should be excluded from the result even if present. Note that this was implicitly NA in R <= 3.3.1 which did drop NA levels even when present in x, contrary to the documentation. The current default is compatible with x[ ,
2019 May 30
2
stopifnot
Here is a patch to function 'stopifnot' that adds 'evaluated' argument and makes 'exprs' argument in 'stopifnot' like 'exprs' argument in 'withAutoprint'.
--- stop.R 2019-05-30 14:01:15.282197286 +0000
+++ stop_new.R 2019-05-30 14:01:51.372187466 +0000
@@ -31,7 +31,7 @@
.Internal(stop(call., .makeMessage(..., domain = domain)))
}
2017 Nov 04
1
ans[nas] <- NA in 'ifelse' (was: ifelse() woes ... can we agree on a ifelse2() ?)
Removal of
ans[nas] <- NA
from the code of function 'ifelse' in R is not committed (yet). Why?
--------------------------------------------
On Mon, 28/11/16, Martin Maechler <maechler at stat.math.ethz.ch> wrote:
Subject: Re: [Rd] ifelse() woes ... can we agree on a ifelse2() ?
Cc: R-devel at r-project.org, maechler at stat.math.ethz.ch
Date: Monday, 28 November, 2016, 10:00
2016 Sep 02
2
Coercion of 'exclude' in function 'factor' (was 'droplevels' inappropriate change)
I am basically fine with the change.
How about using just the following?
if(!is.character(exclude))
exclude <- as.vector(exclude, typeof(x)) # may result in NA
x <- as.character(x)
It looks simpler and is, more or less, equivalent.
In factor.Rd, in description of argument 'exclude', "(when \code{x} is a \code{factor} already)" can be removed.
A larger
2016 Aug 14
2
table(exclude = NULL) always includes NA
useNA <- if (missing(useNA) && !missing(exclude) && !(NA %in% exclude)) "ifany"
An example where it change 'table' result for non-factor input, from https://stat.ethz.ch/pipermail/r-help/2005-April/069053.html :
x <- c(1,2,3,3,NA)
table(as.integer(x), exclude=NaN)
I bring the example up, in case that the change in result is not intended.
2019 Mar 31
3
stopifnot
Ah, with R 3.5.0 or R 3.4.2, but not with R 3.3.1, 'eval' inside 'for' makes compiled version behave like non-compiled version.
options(error = expression(NULL))
library(compiler)
enableJIT(0)
f <- function(x) for (i in 1) {x; eval(expression(i))}
f(is.numeric(y))
# Error: object 'y' not found
fc <- cmpfun(f)
fc(is.numeric(y))
# Error: object 'y' not found
2012 Dec 06
2
factor(x, exclude=y) if x is a factor
I found this part in the documentation of 'factor'.
'factor(x, exclude=NULL)' applied to a factor is a no-operation
unless there are unused levels: in that case, a factor with the
reduced level set is returned. If 'exclude' is used it should
also be a factor with the same level set as 'x' or a set of codes
for the levels to be excluded.
2017 May 18
2
stopifnot() does not stop at first non-TRUE argument
>From an example in http://www.uni-muenster.de/ZIV.BennoSueselbeck/s-html/helpfiles/nargs.html , number of arguments in '...' can be obtained by
(function(...)nargs())(...) .
I now realize that sys.call() doesn't expand '...' when the function is called with '...'. It just returns the call as is. If 'stopifnot' uses sys.call() instead of match.call() , the
2017 Aug 19
1
Issues of R_pretty in src/appl/pretty.c
Yes, they work now.
I mentioned them partly because the commit description said overflow for large n and partly to be considered for regression tests.
--------------------------------------------
On Sat, 19/8/17, Martin Maechler <maechler at stat.math.ethz.ch> wrote:
Subject: Re: [Rd] Issues of R_pretty in src/appl/pretty.c
Cc: r-devel at r-project.org
Date: Saturday, 19 August, 2017,
2017 Aug 18
1
Issues of R_pretty in src/appl/pretty.c
Examples similar to
pretty(c(-1,1)*1e300, n = 1e9, min.n = 1)
with smaller 'n':
pretty(c(-1,1)*1e304, n = 1e5, min.n = 1)
pretty(c(-1,1)*1e306, n = 1e3, min.n = 1)
A report on 'pretty' when working with integers, similar to what led to change of 'seq' fuzz, is https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15137
--------------------------------------------
On Tue,
2017 Aug 11
2
Issues of R_pretty in src/appl/pretty.c
See https://stat.ethz.ch/pipermail/r-devel/2017-August/074746.html for the origin of the example here.
That
pretty(c(-1,1)*1e300, n = 1e9, min.n = 1) gave 20 intervals, far from 1e9, but
pretty(c(-1,1)*1e300, n = 1e6, min.n = 1) gave 1000000 intervals
(on a machine), made me trace through the code to function 'R_pretty' in https://svn.r-project.org/R/trunk/src/appl/pretty.c .
*lo is
2019 Apr 01
1
[External] Re: stopifnot -- eval(*) inside for()
On Mon, 1 Apr 2019, Martin Maechler wrote:
>>>>>> Suharto Anggono Suharto Anggono via R-devel
>>>>>> on Sun, 31 Mar 2019 15:26:13 +0000 writes:
>
> > Ah, with R 3.5.0 or R 3.4.2, but not with R 3.3.1, 'eval'
> > inside 'for' makes compiled version behave like
> > non-compiled version.
>
> Ah.. ... thank
2016 Aug 15
1
table(exclude = NULL) always includes NA
>>>>> Martin Maechler <maechler at stat.math.ethz.ch>
>>>>> on Mon, 15 Aug 2016 11:07:43 +0200 writes:
>>>>> Suharto Anggono Suharto Anggono <suharto_anggono at yahoo.com>
>>>>> on Sun, 14 Aug 2016 03:42:08 +0000 writes:
>> useNA <- if (missing(useNA) && !missing(exclude) && !(NA %in%
2019 Mar 05
2
stopifnot
Another possible shortcut definition:
assert <- function(exprs)
do.call("stopifnot", list(exprs = substitute(exprs), local = parent.frame()))
After thinking again, I propose to use
??? ? ? stop(simpleError(msg, call = if(p <- sys.parent()) sys.call(p)))
- It seems that the call is the call of the frame where stopifnot(...) is evaluated. Because that is the correct context, I
2018 Mar 24
1
Function 'factor' issues
I am trying once again.
By just changing
f <- match(xlevs[f], nlevs)
to
f <- match(xlevs, nlevs)[f]
, function 'factor' in R devel could be made more consistent and back-compatible. Why not picking it?
--------------------------------------------
On Sat, 25/11/17, Suharto Anggono Suharto Anggono <suharto_anggono at yahoo.com> wrote:
Subject: Re: [Rd] Function
2024 Nov 25
1
Alternative to some recently changed parts of dates.R and datetime.R
In?function?'Summary.Date'?in?dates.R?,
..1
could?be?used?instead?of
...elt(1L)
In?function?'format.POSIXlt'?in?datetime.R?,
unlist(unclass(x)[1L:3L],?use.names=FALSE)
could?be?used?instead?of
unlist(`names<-`(unclass(x)[1L:3L],?NULL))
Also, the fragment
secs <- x$sec[f0]; secs <- secs[is.finite(secs)]
could be put inside
if(np?>=?1L)