Displaying 20 results from an estimated 8000 matches similar to: "Debugging warnings"
2012 Jan 06
1
seq_along and rep_along
Hi all,
A couple of ideas for improving seq_along:
* It would be really useful to have a second argument dim:
seq_along(mtcars, 1)
seq_along(mtcars, 2)
# equivalent to
seq_len(dim(mtcars)[1])
seq_len(dim(mtcars)[2])
I often find myself wanting to iterate over the rows or column of a
data frame, and there isn't a particularly nice idiom if you want to
avoid problems
2019 Mar 02
0
stopifnot
Instead of
if(!is.null(names(cl))) names(cl) <- NULL ,
just
names(cl) <- NULL
looks simpler and the memory usage and speed is not bad in my little experiment.
--------------------------------------------
Subject: Re: [Rd] stopifnot
To: r-devel at r-project.org
Date: Saturday, 2 March, 2019, 3:28 PM
[...]
A revised patch (also with simpler 'cl'):
--- stop.R 2019-02-27
2019 Mar 02
1
stopifnot
A private reply by Martin made me realize that I was wrong about
stopifnot(exprs=TRUE) .
It actually works fine. I apologize. What I tried and was failed was
stopifnot(exprs=T) .
Error in exprs[[1]] : object of type 'symbol' is not subsettable
The shortcut
assert <- function(exprs) stopifnot(exprs = exprs)
mentioned in "Warning" section of the documentation similarly fails
2019 Mar 05
0
stopifnot
>>>>> Suharto Anggono Suharto Anggono
>>>>> on Tue, 5 Mar 2019 17:29:20 +0000 writes:
> Another possible shortcut definition:
> assert <- function(exprs)
> do.call("stopifnot", list(exprs = substitute(exprs), local = parent.frame()))
Thank you. I think this is mostly a matter of taste, but I
liked your version using eval()
2012 Jul 12
1
Modifying a list: what gets copied?
Hi all,
In my continued effort to understand when and what R copies, I've
designed a small experiment to try and figure out what goes on when a
list gets copied - is it a shallow copy or a deep copy. I believe the
following experiment isolates the difference:
options(digits = 2)
powers <- 4:6
n <- setNames(10 ^ powers, paste0("e", powers))
xs <- lapply(n, seq_len)
zs <-
2010 Sep 10
0
plyr: version 1.2
plyr is a set of tools for a common set of problems: you need to
__split__ up a big data structure into homogeneous pieces, __apply__ a
function to each piece and then __combine__ all the results back
together. For example, you might want to:
* fit the same model each patient subsets of a data frame
* quickly calculate summary statistics for each group
* perform group-wise transformations
2010 Sep 10
0
plyr: version 1.2
plyr is a set of tools for a common set of problems: you need to
__split__ up a big data structure into homogeneous pieces, __apply__ a
function to each piece and then __combine__ all the results back
together. For example, you might want to:
* fit the same model each patient subsets of a data frame
* quickly calculate summary statistics for each group
* perform group-wise transformations
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
2019 Mar 07
0
stopifnot
By not using 'withCallingHandler' or 'tryCatch', the state is like 'stopifnot' in R 3.4.x. If 'stopifnot' becomes faster than in R 3.4.x when the expressions given to 'stopifnot' are all TRUE, it is because 'match.call' is not called. Credit is to https://github.com/HenrikBengtsson/Wishlist-for-R/issues/70 for the idea.
Speaking about
2011 Dec 23
1
Debugging namespace problems
Hi all,
I frequently find that I've failed to export something in my NAMESPACE
and hence my package doesn't work when it's imported into another
package. Does anyone have suggestion for debugging this type of
problem? R CMD check passes without any ns related errors on both the
importee and the importer.
I've attached a reproducible example - if you install the development
2010 Jun 29
4
Tips for debugging: R CMD check examples
Hi all,
Does anyone have any suggestions for debugging the execution of
examples by R CMD check? The examples work fine when I run them from
a live R prompt, but I get errors when they are run by R CMD check.
Thanks,
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
2011 Aug 16
2
sysdata.rda, namespaces and package dependencies
Hi all,
I'm struggling with accessing a package dataset (munsell.map, stored
in sysdata.rda) when that package is imported, not required. A simple
reproducible example is:
install.packages("munsell")
munsell::mnsl("10B 4/6")
# Error in match(col, munsell.map$name) : object 'munsell.map' not found
library(munsell)
munsell::mnsl("10B 4/6")
# Function
2010 Aug 27
2
NEWS and readNEWS
readNEWS() states:
Read R's ?NEWS? file or a similarly formatted one. This is an
experimental feature, new in R 2.4.0 and may change in several
ways
and news() also indicates that this tool is supposed to work with
non-R news files. However, I've not been able to get readNEWS to read
a package news file, even when following the format indicated in
news(). Looking at the
2010 Nov 09
3
How to detect if a vector is FP constant?
Hi all,
What's the equivalent to length(unique(x)) == 1 if want to ignore
small floating point differences? Should I look at diff(range(x)) or
sd(x) or something else? What cut off should I use?
If it helps to be explicit, I'm interested in detecting when a vector
is constant for the purpose of visual display. In other words, if I
rescale x to [0, 1] do I have enough precision to get
2011 Dec 31
4
Base function for flipping matrices
Hi all,
Are there base functions that do the equivalent of this?
fliptb <- function(x) x[nrow(x):1, ]
fliplr <- function(x) x[, nrow(x):1]
Obviously not hard to implement (although it needs some more checks),
just wondering if it had already been implemented.
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
2010 Aug 24
3
require is to suggests as what is to imports?
Hi all,
If a package suggests another package in its description, you can
check it at runtime with requires. How do you do check if a package
is available without loading it, if you only want to access one
function in the package namespace.
Thanks,
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
2011 Sep 21
3
Quelplot
Hi all,
Does anyone have an R implementation of the queplot (K.?M. Goldberg
and B.?Iglewicz. Bivariate extensions of the boxplot. Technometrics,
34(3):pp. 307?320, 1992)? I'm struggling with the estimation of the
asymmetry parameters.
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
2010 Sep 29
1
License of R manuals
Hi all,
Under what license are the R manuals (R language definition etc)
released? They are not mentioned explicitly in license() and have no
license information in the individual documents. Does this mean that
they are released under GPL-2? If so, what does that mean, given that
they aren't software?
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics
2011 Feb 07
1
Save and serialize
Hi all,
Is there any relationship between save and serialize? Do they use the
same algorithm?
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
2012 Mar 20
1
Substitute adds id attribute?
Hi all,
I can't figure out how to make this problem easily reproducible, but I
can demonstrate it very simply, so I hoped someone might be able to
suggest a place to start:
> f <- function(x) substitute(x)
> f(x)
x
> f(mpg)
mpg
attr(,"id")
[1] 11
It works as expected in a clean R session:
> f <- function(x) substitute(x)
> f(x)
x
> f(mpg)
mpg
but not