similar to: Best practices for writing R functions (really copying)

Displaying 20 results from an estimated 11000 matches similar to: "Best practices for writing R functions (really copying)"

2016 Sep 09
3
R (development) changes in arith, logic, relop with (0-extent) arrays
> Radford Nea: > > So it may make more sense to move towards consistency in the > > permissive direction, rather than the restrictive direction. > > > That would mean allowing matrix(1,1,1) < (1:2), and maybe also things > > like matrix(1,2,2)+(1:8). > > Martin Maechler: > That is an interesting idea. Yes, in my view that would >
2015 Mar 01
1
iterated lapply
> There are other instances, such as Reduce where there is a bug > report pending that amounts to the same issue. Performing surgery on > expressions and calling eval is not good practice at the R level and > probably not a good idea at the C level either. It is worth thinking > this through carefully before a adopting a solution, which is what we > will be doing. Surgery on
2018 Nov 27
1
Subsetting row in single column matrix drops names in resulting vector
Dmitriy Selivanov (selivanov.dmitriy at gmail.com) wrote: > Consider following example: > > a = matrix(1:2, nrow = 2, dimnames = list(c("row1", "row2"), c("col1"))) > a[1, ] > # 1 > > It returns *unnamed* vector `1` where I would expect named vector. In fact > it returns named vector when number of columns is > 1. > Same issue applicable
2015 Mar 01
2
iterated lapply
I think the discussion of this issue has gotten more complicated than necessary. First, there really is a bug. You can see this also by the fact that delayed warning messages are wrong. For instance, in R-3.1.2: > lapply(c(-1,2,-1),sqrt) [[1]] [1] NaN [[2]] [1] 1.414214 [[3]] [1] NaN Warning messages: 1: In FUN(c(-1, 2, -1)[[3L]], ...) : NaNs produced 2: In
2015 Jun 13
2
Lack of protection bug in current R release candidate
The current R release candidate has a lack of protect bug (of very long standing) with respect to the R_print.na_string and R_print.na_string_noquote fields of the static R_print structure declared in Print.h. This shows up very occassionally as incorrect output from the following lines in reg-tests-2.R: x <- c("a", NA, "b") factor(x) factor(x, exclude="")
2015 Jul 14
3
Two bugs showing up mostly on SPARC systems
In testing pqR on Solaris SPARC systems, I have found two bugs that are also present in recent R Core versions. You can see the bugs and fixes at the following URLs: https://github.com/radfordneal/pqR/commit/739a4960a4d8f3a3b20cfc311518369576689f37 https://github.com/radfordneal/pqR/commit/339b7286c7b43dcc6b00e51515772f1d7dce7858 The first bug, in nls, is most likely to occur on a 64-bit
2019 Feb 04
2
Inefficiency in df$col
> > I think you might want to just delete the definition of $.data.frame, > > reverting to the situation before R-3.1.0. > > I imagine the cause is that the list version is done in C code rather > than R code (i.e. there's no R function `$.list`). So an alternative > solution would be to also implement `$.data.frame` in the underlying C > code. This won't
2019 Feb 04
3
Inefficiency in df$col
Does either of you have a patch against current R-devel? I tried the obvious, but the build dies with building package 'tools' all.R is unchanged ../../../../library/tools/libs/x86_64/tools.so is unchanged installing 'sysdata.rda' Error in get(method, envir = home) : object '$.data.frame' not found Error: unable to load R code in package 'tools' Execution halted
2018 May 03
2
Proposed speedup of ifelse
> I propose a patch to ifelse that leverages anyNA(test) to achieve an > improvement in performance. For a test vector of length 10, the change > nearly halves the time taken and for a test of length 1 million, there > is a tenfold increase in speed. Even for small vectors, the > distributions of timings between the old and the proposed ifelse do > not intersect. For smaller
2016 Sep 08
2
R (development) changes in arith, logic, relop with (0-extent) arrays
Regarding Martin Maechler's proposal: Arithmetic between length-1 arrays and longer non-arrays had silently dropped the array attributes and recycled. This now gives a warning and will signal an error in the future, as it has always for logic and comparison operations For example, matrix(1,1,1) + (1:2) would give a warning/error. I think this might be a mistake. The potential
2015 Aug 21
2
OpenMP problem with 64-bit Rtools
I've been getting pqR to work on windows systems, and in the process have discovered various problems with R core versions of R and with Rtools. One is with the implementation of OpenMP in 64-bit Rtools. This problem is in Rtools215 and Rtools33, and presumably all the ones in between. You can see the problem with the following test program: #include <stdio.h> #include <omp.h>
2015 Jun 15
1
Lack of protection bug in current R release candidate
> > The current R release candidate has a lack of protect bug > > (of very long standing) > > [ but not really reported, right ? ] It's "long standing" because it exists in versions of R going back many years. > but the R 3.2.1 release candidate probably really cannot be > touched now, with something non-trivial like this. > > We'd be
2010 Oct 18
1
make error for R 2.13.0 (and 2.12.0)
Regarding Tengfei Yin's post about an error trying to install "cluster" in 2.13.0, I have gotten an error with this package when trying to install the released version of 2.12.0. Here is the output on an Ubuntu Linux system: begin installing recommended package cluster * installing *source* package 'cluster' ... ** libs make[3]: Entering directory
2013 Mar 12
2
Bugs due to naive copying of list elements
Several bugs are present in R-2.15.3 and R-alpha due to naive copying of list elements. The bug below is due to naive copying in subset.c (with similar bugs for matrices and arrays): a<-list(c(1,2),c(3,4),c(5,6)) b<-a[2:3] a[[2]][2]<-9 print(b[[1]][2]) Naive copying in mapply.c leads to the following bug: X<-1+1 f<-function(a,b) X A<-mapply(f,c(1,2,3),c(4,5,6),SIMPLIFY=FALSE)
2015 Feb 18
3
Recycling memory with a small free list
> ... with assignments inside of loops like this: > > reweight = function(iter, w, Q) { > for (i in 1:iter) { > wT = w * Q > } > } > ... before the RHS is executed, the LHS allocation would be added > to a small fixed length list of available space which is checked > before future allocations. If the same size is requested before the > next garbage
2017 Jun 16
4
[WISH / PATCH] possibility to split string literals across multiple lines
> On Wed, 14 Jun 2017, G?bor Cs?rdi wrote: > > > I like the idea of string literals, but the C/C++ way clearly does not > > work. The Python/Julia way might, i.e.: > > > > """this is a > > multi-line > > lineral""" > > luke-tierney at uiowa.edu: > This does look like a promising option; some more careful checking
2015 Jun 17
1
Add-on argument in sample()
> Then the question would be if this test could be replaced with a new > argument to sample, e.g. expandSingle, which has TRUE as default for > backward compatibility, but FALSE if you dont want population to be > expanded to 1:population. It could certainly be useful in some cases, > but you still need to know about the expansion to use it. I think most > of these bugs
2016 Sep 12
1
R (development) changes in arith, logic, relop with (0-extent) arrays
> > But isn't the intent to make it an error later? So I assume we're > > debating making it an error, not just a warning. > > Yes, that's correct. > But if we have a longish deprecation period (i.e. where there's > only a warning) all important code should have been adapted > before it turns to an error That might be true for
2014 Mar 26
2
R-devel Digest, Vol 133, Issue 23
> From: Richard Cotton <richierocks at gmail.com> > > The rep function is very versatile, but that versatility comes at a > cost: it takes a bit of effort to learn (and remember) its syntax. > This is a problem, since rep is one of the first functions many > beginners will come across. Of the three main uses of rep, two have > simpler alternatives. > > rep(x,
2015 Feb 24
3
iterated lapply
From: Daniel Kaschek <daniel.kaschek at physik.uni-freiburg.de> > ... When I evaluate this list of functions by > another lapply/sapply, I get an unexpected result: all values coincide. > However, when I uncomment the print(), it works as expected. Is this a > bug or a feature? > > conditions <- 1:4 > test <- lapply(conditions, function(mycondition){ >