Displaying 20 results from an estimated 20000 matches similar to: "class() on substitute(...) output?"
2015 May 13
1
Why is the diag function so slow (for extraction)?
As kindly pointed out to me (oh my decaying gray matter), is.object()
is better suited for this test;
$ svn diff src/library/base/R/diag.R
Index: src/library/base/R/diag.R
===================================================================
--- src/library/base/R/diag.R (revision 68345)
+++ src/library/base/R/diag.R (working copy)
@@ -23,9 +23,11 @@
stop("'nrow' or
2015 Jun 01
2
sum(..., na.rm=FALSE): Summing over NA_real_ values much more expensive than non-NAs for na.rm=FALSE? Hmm...
I'm observing that base::sum(x, na.rm=FALSE) for typeof(x) == "double"
is much more time consuming when there are missing values versus when
there are not. I'm observing this on both Window and Linux, but it's
quite surprising to me. Currently, my main suspect is settings in on
how R was built. The second suspect is my brain. I hope that someone
can clarify the below
2015 May 12
2
Why is the diag function so slow (for extraction)?
>>>>> Steve Bronder <sbronder at stevebronder.com>
>>>>> on Thu, 7 May 2015 11:49:49 -0400 writes:
> Is it possible to replace c() with .subset()?
It would be possible, but I think "entirely" wrong.
.subset() is documented to be an internal function not to be
used "lightly" and more to the point it is documented to *NOT*
2015 Sep 20
2
Long vectors: Missing values and R_xlen_t?
Is there a missing value constant defined for R_xlen_t, cf. NA_INTEGER
(== R_NaInt == INT_MIN) for int(eger)? If not, is it correct to
assume that missing values should be taken care/tested for before
coercing from int or double?
Thank you,
Henrik
2014 May 01
3
How to test if an object/argument is "parse tree" - without evaluating it?
This may have been asked before, but is there an elegant way to check
whether an variable/argument passed to a function is a "parse tree"
for an (unevaluated) expression or not, *without* evaluating it if
not?
Currently, I do various rather ad hoc eval()+substitute() tricks for
this that most likely only work under certain circumstances. Ideally,
I'm looking for a isParseTree()
2015 Jan 26
2
Inspect a "delayed" assigned whose value throws an error?
On Mon, Jan 26, 2015 at 12:24 PM, Hadley Wickham <h.wickham at gmail.com> wrote:
> If it was any other environment than the global, you could use substitute:
>
> e <- new.env()
> delayedAssign("foo", stop("Hey!"), assign.env = e)
> substitute(foo, e)
>
> delayedAssign("foo", stop("Hey!"))
> substitute(foo)
Hmm... interesting
2006 Feb 13
2
?bug? strange factors produced by chron
Hallo all
Please help me. I am lost and do not know what is the problem. I have
a factor called kvartaly.
> attributes(kvartaly)
$levels
[1] "1Q.04" "2Q.04" "3Q.04" "4Q.04" "1Q.05" "2Q.05" "3Q.05" "4Q.05"
$class
[1] "factor"
> mode(kvartaly)
[1] "numeric"
> str(kvartaly)
Factor w/ 8
2013 Dec 17
3
In-string variable/symbol substitution: What formats/syntax is out there?
Hi,
I'm try to collect a list of methods/packages available in R for doing
in-string variable/symbol substitution, e.g. someFcn("pi=${pi}"),
anotherFcn("pi=@pi@") and so on becomes "pi=3.141593". I am aware of
the following:
** gsubfn() in the 'gsubfn' package, e.g.
> gsubfn( , , "pi = $pi, 2pi = `2*pi`")
[1] "pi = 3.14159265358979,
2013 Aug 30
2
"False" warning on "replacing previous import" when re-exporting identical object
Hi,
SETUP:
Consider three packages PkgA, PkgB and PkgC.
PkgA defines a generic function foo() and exports it;
export(foo)
PkgB imports PkgA::foo() and re-exports it;
importFrom(PkgA, foo)
export(foo)
PkgC imports everything from PkgA and PkgB:
imports(PkgA, PkgB)
PROBLEM:
Loading or attaching the namespace of PkgC will generate a warning:
replacing previous import by
2019 Oct 31
2
head.matrix can return 1000s of columns -- limit to n or add new argument?
Hmm, the problem I see here is that these implied classes are all inherently one-off. We also have
> inherits(matrix(1,1,1),"numeric")
[1] FALSE
> is.numeric(matrix(1,1,1))
[1] TRUE
> inherits(1L,"numeric")
[1] FALSE
> is.numeric(1L)
[1] TRUE
and if we start fixing one, we might need to fix all.
For method dispatch, we do have inheritance, e.g.
>
2012 May 22
2
Best way to locate R executable from within R?
Hi,
I'd like to spawn of a new R process from within R using system(),
e.g. system("R -f myScript.R"). However, just specifying "R" as in
that example is not guaranteed to work, because "R" may not be on the
OS's search path.
What is the best way, from within a running R, to infer the command
(basename or full path) for launching R in way that it works on
2010 Nov 03
3
Using sample() to sample one value from a single value?
Hi, consider this one as an FYI, or a seed for further discussion.
I am aware that many traps on sample() have been reported over the
years. I know that these are also documents in help("sample"). Still
I got bitten by this while writing
sample(units, size=length(units));
where 'units' is an index (positive integer) vector. It works in all
cases as expected (=I expect)
2015 Jan 26
2
Inspect a "delayed" assigned whose value throws an error?
Hi, I got an interesting programming challenge:
How do you inspect an object which is assigned via delayedAssign() and
that throws an error as soon as it is "touched" (=the value is
evaluated)? Is it possible?
MINIMAL EXAMPLE:
$ R --vanilla
> delayedAssign("foo", stop("Hey!"))
(If you find this minimal example silly/obvious, please skip down to
the real
2011 Nov 07
3
CRAN: How to list a non-Sweave doc under "Vignettes:" on package page?
Hi,
is it possible to have non-Sweave vignettes(*) in inst/doc/ be listed
under 'Downloads' on CRAN package pages? For instance, in my R.rsp
package I have a inst/doc/report.pdf (part of the source *.tar.gz)
that is not detected/listed. The PDF is not based on a Sweave
vignette but an *.tex.rsp vignette that is dynamically created via
inst/doc/Makefile. It is listed
(*) BTW, can the
2015 Feb 01
2
Output to "raw console" rather than stdout/stderr?
In R, there's readline(), which is great because you can prompt the user, e.g.
ans <- readline("Would you like to install Pandoc? [y/N]: ")
without having to worry the message is intercepted by
capture.output(), sink() or similar (which is used by dynamic report
generators among other things). The message will always reach the
user. (You can use sink(...,
2016 Oct 12
2
How to assign NULL value to pairlist element while keeping it a pairlist?
Thanks, this was what I expected. There is a desire to eliminate the
usage of pairlist from user code, which suggests the alternative of
allowing for function arguments to be stored in lists. That's a much
deeper change though.
On Wed, Oct 12, 2016 at 12:31 PM, Henrik Bengtsson
<henrik.bengtsson at gmail.com> wrote:
> Michael, thanks for this info.
>
> I've stumbled upon
2005 Aug 06
1
oldClass vs. class
Hi,When I read the source of str,i find these code
-----
## Show further classes // Assume that they do NOT have an own Method --
## not quite perfect ! (.Class = 'remaining classes', starting with current)
cl <- oldClass(object); cl <- cl[cl != "data.frame"] #- not THIS class
-----
so I use ?oldClass to try to learn more about oldClass.But after I have reading
2010 Jul 29
1
Using 'dimname names' in aperm() and apply()
I think that the "dimname names" of tables and arrays could make
aperm() and apply() (and probably some other functions) easier to use.
(dimname names are, for example, created by table() )
The use would be something like:
--
x <-table( from=sample(3,100,rep=T), to=sample(5,100,rep=T))
trans <- x / apply(x,"from",sum)
y <- aperm( trans,
2012 Apr 16
1
eval a SYMSXP from C
Can someone offer some advice on how to properly evaluate a SYMSXP
from a .Call ?
I have the following in R:
variable xn, with an attribute "mu" which references the variable mu
in the global environment.
I know "references" is a loose term; mu was defined in this fashion as
a way to implement deferred binding:
foo <- function(x,mu) {
attr(x,"mu") <-
2016 Oct 19
2
How to assign NULL value to pairlist element while keeping it a pairlist?
On Sat, Oct 15, 2016 at 2:00 AM, Martin Maechler
<maechler at stat.math.ethz.ch> wrote:
>>>>>> Michael Lawrence <lawrence.michael at gene.com>
>>>>>> on Wed, 12 Oct 2016 15:21:13 -0700 writes:
>
> > Thanks, this was what I expected. There is a desire to
> > eliminate the usage of pairlist from user code, which
> >