Displaying 20 results from an estimated 4000 matches similar to: "how to interpose my own "[" function?"
2005 Oct 09
3
[ subscripting sometimes loses names (PR#8192)
--rwEMma7ioTxnRzrJ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
R, like recent versions of S-Plus, sometimes - but not always - loses
names when subscripting objects with "[". (Earlier versions of S and
S-Plus had the correct, name-preserving behavior.) This seems bad, it
would be better to remove names only by explicit request, not as an
accidental
2009 Jun 12
1
Rprof loses all system() time
Rprof seems to ignore all time spent inside system() calls. E.g.,
this simple example actually takes about 10 seconds, but Rprof thinks
the total time is only 0.12 seconds:
> Rprof("sleep-system.out") ; system.time(system(command="sleep 10")) ; Rprof(NULL)
user system elapsed
0.000 0.004 10.015
> summaryRprof("sleep-system.out")$by.total
2014 Apr 24
2
palette() can hang and fail due to X11
For many years, when my R process starts up I've been automatically
setting my preferred default plot colors, basically like so:
my.colors <-
c("black" ,"red" ,"gold" ,"sky blue" ,"green" ,"blue" ,"orange"
,"grey" ,"hot pink" ,"brown" ,"sea green" ,"cyan"
2007 Oct 24
2
R trunk (2.7) build fails with -fpic, needs -fPIC (PR#10372)
On Linux x86-64 (Ubuntu 6.06), the latest R sources from the
Subversion trunk fail to build with the following "recompile with
-fPIC" error:
$ ./configure --with-x=yes --prefix=$inst_dir --enable-R-shlib --with-tcltk=/usr/lib/tcl8.4 --with-tcl-config=/usr/lib/tcl8.4/tclConfig.sh
$ make
/usr/bin/ld: ../appl/approx.o: relocation R_X86_64_32 against `a local symbol' can not be
2014 Apr 21
1
read.table() code fails outside of the utils package
One of the great things about R is how readable and re-usable much of
its own implementation is. If an R function doesn't do quite what you
want but is close, it is usually very easy to read its code and start
adapting that as the base for a modified version.
In the 2.x versions of R, that was the case with read.table(). It was
easy to experiment with its source code, as it all worked just
2008 Sep 05
2
typo in cov()? var() fails on NA in R 2.7.2 but not R 2.6.1
I recently started using R 2.7.2, and noticed a surprising change in
the behavior of var() on NA data:
R 2.6.1 (Patched), 2007-11-26, svn.rev 43541, x86_64-unknown-linux-gnu:
> stdev(rep(NA,3), na.rm=F)
[1] NA
> stdev(rep(NA,3), na.rm=T)
[1] NA
> var(rep(NA,3), na.rm=T, use="complete.obs")
[1] NA
R 2.7.2 (Patched), 2008-09-02, svn.rev 46491,
2003 Dec 31
2
Calling primitive functions from C code
Does anyone have an example of calling primitive or internal functions from
C code that they would share with me?
I am having trouble trying to figure out how to construct the proper
arguments to pass to "do_subset_dflt"
Here is the prototype:
SEXP do_subset_dflt(SEXP call, SEXP op, SEXP args, SEXP rho);
The R_FunTab from "names.c" gives some additional information on the
2003 Dec 31
2
Calling primitive functions from C code
Does anyone have an example of calling primitive or internal functions from
C code that they would share with me?
I am having trouble trying to figure out how to construct the proper
arguments to pass to "do_subset_dflt"
Here is the prototype:
SEXP do_subset_dflt(SEXP call, SEXP op, SEXP args, SEXP rho);
The R_FunTab from "names.c" gives some additional information on the
2010 Oct 27
2
must .Call C functions return SEXP?
For using R's .Call interface to C functions, all the examples I've
seen have the C function return type SEXP. Why? What does R actually
do with this return type? What happens if I *don't* return a SEXP?
Reason I ask, is I've written some R code which allocates two long
lists, and then calls a C function with .Call. My C code writes to
those two pre-allocated lists, thus, I
2006 Jan 11
3
natural sorting
It would be nifty to incorporate this into R or into an R package:
http://sourcefrog.net/projects/natsort/
2023 Oct 24
1
as.character.Date() strips names in R 4.3.2 beta, bug?
>>>>> Andrew Piskorski
>>>>> on Tue, 24 Oct 2023 00:01:58 -0400 writes:
> In previous versions of R,
Not in R 4.3.0 or 4.3.1 {you are a bit late with updating ..}.
> as.character.Date() retained any names on
> its input vector. In R 4.3.2 beta, it removes names. Is this change
> intentional, or a bug? (For what it's
2014 Apr 18
1
Why did R 3.0's resolveNativeRoutine remove full-search ability?
In versions of R prior to 3.0, by default .C and .Call would find the
requested C function regardless of which shared library it was located
in. You could use the PACKAGE argument to restrict the search to a
specific library, but doing so was not necessary for it to work.
R 3.0 introduced a significant change to that behavior; from the NEWS
file:
CHANGES IN R 3.0.0:
PERFORMANCE
2011 Sep 14
3
make check reg-tests-1b.R fails with Ubuntu R
Today I built R from source on a 32-bit Ubuntu 10.04.3 LTS box, and
saw that the "make check" tests/reg-tests-1b.R failed. From the
output at the end of my "tests/reg-tests-1b.Rout.fail" file, the
problem is appearing in the "identical(z, x %*% t(y))" test code
below.
I then tried the stock R provided by the Ubuntu r-base-core binary
package, and to my surprise, it
2010 May 14
1
debugging substitute function in R 2.11
Dear list,
A while ago I found in the web a function (sadly I can't credit the
author as I don't remember where I picked it up from) whose output is
a dataframe that lists for every object in the global environment its
class, mode, dim & length (where applicable). It is meant to be an
upgrade to the ls () function with a far more informative and detailed
output and it quickly became
2005 Oct 09
0
all.equal() improvements (PR#8191)
--k1lZvvs/B4yU6o8G
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
The attached patch against R 2.2.0 makes the following improvements to
the all.equal() function:
1. Check names! Stock R all.equal() (unlike S-Plus) ignores names
completely on some objects. I consider this wrong - if the names
are different, the object is NOT "the same".
2. When a
2006 Apr 04
2
Return function from function with minimal environment
Hi,
this relates to the question "How to set a former environment?" asked
yesterday. What is the best way to to return a function with a
minimal environment from a function? Here is a dummy example:
foo <- function(huge) {
scale <- mean(huge)
function(x) { scale * x }
}
fcn <- foo(1:10e5)
The problem with this approach is that the environment of 'fcn' does
not
2007 Aug 22
3
integrate
Hi,
I am trying to integrate a function which is approximately constant
over the range of the integration. The function is as follows:
> my.fcn = function(mu){
+ m = 1000
+ z = 0
+ z.mse = 0
+ for(i in 1:m){
+ z[i] = rnorm(1, mu, 1)
+ z.mse = z.mse + (z[i] - mu)^2
+ }
+ return(z.mse/m)
+ }
> my.fcn(-10)
[1] 1.021711
> my.fcn(10)
[1] 0.9995235
> my.fcn(-5)
[1] 1.012727
> my.fcn(5)
2005 Aug 03
1
tree/graph data structure APIs?
What is the best code available for simple general purpose
manipulation of tree (and/or directed graph) data structures in R?
Looking through CRAN, I see a bunch of packages for stastical
regression trees, but nothing that seems to provide an API for
manipulating tree data structures. What I'm looking for is something
along the lines of an R version of the Tcllib ::struct::tree API
available
2005 Jul 05
1
build R source package in place from CVS?
I'm currently using R CMD INSTALL to build and install some of my own
custom R packages. Basically, I use a script which first builds a
tarball of my R source code, and then calls R CMD INSTALL, which
builds and installs that source package from the tarball, including
re-compiling all my C code from scratch every single time, which is
both totally unneccessary and tediously slow.
What I
2010 Jun 09
2
OOP and passing by value
Greetings,
I love the R system and am sincerely grateful for the great effort the
product and contributors
are delivering.
My question is as follows:
I am trying to use S4 style classes but cannot write functions that modify
an object
because paramter passing is by value.
For example I want to do this:
setGeneric("setData", function(this,fcn,k){ standardGeneric("setData")