similar to: x[c()] <- value sets the mode to mode(value)

Displaying 20 results from an estimated 30000 matches similar to: "x[c()] <- value sets the mode to mode(value)"

2008 Nov 25
1
Efficient passing through big data.frame and modifying select
> -----Original Message----- > From: William Dunlap > Sent: Tuesday, November 25, 2008 9:16 AM > To: 'johannes_graumann at web.de' > Subject: Re: [R] Efficient passing through big data.frame and > modifying select fields > > > Johannes Graumann johannes_graumann at web.de > > Tue Nov 25 15:16:01 CET 2008 > > > > Hi all, > > > >
2012 Nov 29
1
Non-recursive way to remove empty directory on Windows?
Hi, file.remove(path) will remove an empty directory "on most Unix platforms", but not on Windows, cf. help("file.remove"). A workaround for Windows is then unlink(path, recursive=TRUE). However, unless you're really careful and make sure 'path' is not empty, you may delete more than you wish (even worse, path may contain '..' or likewise from a
2013 May 25
2
Assigning NULL to large variables is much faster than rm() - any reason why I should still use rm()?
Hi, in my packages/functions/code I tend to remove large temporary variables as soon as possible, e.g. large intermediate vectors used in iterations. I sometimes also have the habit of doing this to make it explicit in the source code when a temporary object is no longer needed. However, I did notice that this can add a noticeable overhead when the rest of the iteration step does not take that
2013 Nov 03
1
WISHLIST: on.exit(..., add=TRUE, where="first") to address common use cases
Before trying to submit a patch(*) to on.exit(), I'd like to check whether there is an interest in enhancing on.exit(..., add=TRUE) such that it is possible to specify whether the added expression should be added before or after already recorded expression. The default is now to add it after, but it would often be useful to add it before previously recorded expressions. EXAMPLE: foo <-
2017 Jan 27
1
RFC: tapply(*, ..., init.value = NA)
On Fri, Jan 27, 2017 at 12:34 AM, Martin Maechler <maechler at stat.math.ethz.ch> wrote: > > > On Jan 26, 2017 07:50, "William Dunlap via R-devel" <r-devel at r-project.org> > > wrote: > > > It would be cool if the default for tapply's init.value could be > > FUN(X[0]), so it would be 0 for FUN=sum or FUN=length, TRUE for >
2012 Sep 15
2
Risk of readRDS() not detecting race conditions with parallel saveRDS()?
I hardly know anything about the format used in (non-compressed) serialization/RDS, but hoping someone with more knowledge could give me some feedback; Consider two R processes running in parallel on the same unknown file system. Both of them write and read to the same RDS file foo.rds (without compression) at random times using saveRDS(object, file="foo.rds", compress=FALSE) and
2020 Apr 16
1
Add a new environment variable switch for the 'large version' check
I'd second Jim's feature request - it would be useful to be able to disable this in CI and elsewhere. The concept of using an "unusual" version component such as a very large number does a nice job of indicating "unusual" and serves as a blocker for submitting work-in-progress to CRAN by mistake (hence the validation in 'R CMD check'). Another point, which I
2017 Nov 09
3
check does not check that package examples remove tempdir()
I was looking at the CRAN package 'bfork-0.1.2', which exposes the Unix fork() and waitpid() calls at the R code level, and noticed that the help file example for bfork::fork removes R's temporary directory, the value of tempdir(). I think it happens because the forked process shares the value of tempdir() with the parent process and removes it when it exits. This seems like a
2013 Nov 08
1
Milestone: 5000 packages on CRAN
Here we go again... Today (2011-11-08) on The Comprehensive R Archive Network (CRAN) [1]: "Currently, the CRAN package repository features 5001 available packages." Going from 4000 to 5000 packages took 14.5 months - that's one new package every 10.5 hours. Behind every package there are real people. These user-contributed packages are maintained by ~2900 people [2] - that's
2017 Jun 16
2
R history: Why 'L; in suffix character ‘L’ for integer constants?
Yeah, that was what I heard from our instructor when I was a graduate student: L stands for Long (integer). Regards, Yihui -- https://yihui.name On Fri, Jun 16, 2017 at 11:00 AM, Serguei Sokol <sokol at insa-toulouse.fr> wrote: > Le 16/06/2017 ? 17:54, Henrik Bengtsson a ?crit : >> >> I'm just curious (no complaints), what was the reason for choosing the >> letter
2017 Jan 26
2
RFC: tapply(*, ..., init.value = NA)
On a related note, the storage mode should try to match ans[[1]] (or unlist:ed and) when allocating 'ansmat' to avoid coercion and hence a full copy. Henrik On Jan 26, 2017 07:50, "William Dunlap via R-devel" <r-devel at r-project.org> wrote: It would be cool if the default for tapply's init.value could be FUN(X[0]), so it would be 0 for FUN=sum or FUN=length, TRUE
2018 Mar 13
2
Possible Improvement to sapply
FYI, in R devel (to become 3.5.0), there's isFALSE() which will cut some corners compared to identical(): > microbenchmark::microbenchmark(identical(FALSE, FALSE), isFALSE(FALSE)) Unit: nanoseconds expr min lq mean median uq max neval identical(FALSE, FALSE) 984 1138 1694.13 1218.0 1337.5 13584 100 isFALSE(FALSE) 713 761 1133.53 809.5 871.5
2016 Sep 25
3
withAutoprint({ .... }) ?
>>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com> >>>>> on Sat, 24 Sep 2016 11:31:49 -0700 writes: > Martin, did you post your code for withAutoprint() anywhere? > Building withAutoprint() on top of source() definitely makes sense, > unless, as Bill says, source() itself could provide the same feature. I was really mainly asking
2018 Mar 14
0
Possible Improvement to sapply
>>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com> >>>>> on Tue, 13 Mar 2018 10:12:55 -0700 writes: > FYI, in R devel (to become 3.5.0), there's isFALSE() which will cut > some corners compared to identical(): > > microbenchmark::microbenchmark(identical(FALSE, FALSE), isFALSE(FALSE)) > Unit: nanoseconds > expr
2017 Jun 16
2
R history: Why 'L; in suffix character ‘L’ for integer constants?
Wikipedia claims that C ints are still only guaranteed to be at least 16 bits, and longs are at least 32 bits. So no, R's integers are long. -pd > On 16 Jun 2017, at 20:20 , William Dunlap via R-devel <r-devel at r-project.org> wrote: > > But R "integers" are C "ints", as opposed to S "integers", which are C > "long ints". (I
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()
2016 Sep 23
2
Undocumented 'use.names' argument to c()
I'd vote for it to stay. It could of course suprise someone who'd expect c(list(a=1), b=2, use.names = FALSE) to generate list(a=1, b=2, use.names=FALSE). On the upside, is the performance gain from using use.names=FALSE. Below benchmarks show that the combining of the names attributes themselves takes ~20-25 times longer than the combining of the integers themselves. Also, at no
2020 Apr 16
2
suggestion: "." in [lsv]apply()
I'm sure this exists elsewhere, but, as a trade-off, could you achieve what you want with a separate helper function F(expr) that constructs the function you want to pass to [lsv]apply()? Something that would allow you to write: sapply(split(mtcars, mtcars$cyl), F(summary(lm(mpg ~ wt,.))$r.squared)) Such an F() function would apply elsewhere too. /Henrik On Thu, Apr 16, 2020 at 9:30 AM
2018 Aug 30
1
ROBUSTNESS: x || y and x && y to give warning/error if length(x) != 1 or length(y) != 1
Should the following two functions should always give the same result, except for possible differences in the 'call' component of the warning or error message?: f0 <- function(x, y) x || y f1 <- function(x, y) if (x) { TRUE } else { if (y) {TRUE } else { FALSE } } And the same for the 'and' version? g0 <- function(x, y) x && y g1 <- function(x, y) if
2018 Aug 29
7
ROBUSTNESS: x || y and x && y to give warning/error if length(x) != 1 or length(y) != 1
# Issue 'x || y' performs 'x[1] || y' for length(x) > 1. For instance (here using R 3.5.1), > c(TRUE, TRUE) || FALSE [1] TRUE > c(TRUE, FALSE) || FALSE [1] TRUE > c(TRUE, NA) || FALSE [1] TRUE > c(FALSE, TRUE) || FALSE [1] FALSE This property is symmetric in LHS and RHS (i.e. 'y || x' behaves the same) and it also applies to 'x && y'.