similar to: Functions that write functions in R packages

Displaying 20 results from an estimated 20000 matches similar to: "Functions that write functions in R packages"

2007 Mar 06
2
bug: sticky symbol refs? (PR#9555)
Hello. What happens in the following is that I create two simple functions, f and g, on the workspace. Then I replace g. When I then call f, it uses the old version of g. Now clearly, the circumstances for this to happen must be quite special and rare. But I'd say they're not pathological. It seems to require two things: 1) masked versions of f and g on a search position lower down the
2012 Jan 21
1
Enumerate the class of objects
ls() gives me the vector of objects in the workspace class(objName) gives me the class of objName class(ls()) just returns character as many times as there are objects. How do I get a vector of all objects in the workspace? [[alternative HTML version deleted]]
2004 Mar 23
3
how to modify variables of another frame (but not global)
Hello! Maybe "frame" is not the right term in this context. I explain my problem by example code: fun2 <- function(objName, add) { ## the object "objName" should be increased by "add", ## but the evaluation should be done in the calling function (here: fun1) ## ...... what's the right code?? } fun1 <- function() { x <- 1 fun2("x",
2013 Mar 20
1
S4 Reference Classes: undesired behavior when calling method '$field()'
Dear list, I came across a behavior that IMHO is somewhat undesired when calling '$field()': If the field name whose value you're trying to get is *not* a valid field of the Reference Class, then R doesn't stop there with an error, but scans through all enclosing environments/frames. The result is something similar to calling '|get(<objname>, inherits=TRUE)|'
2015 Feb 16
4
[LLVMdev] Segfault when using llvm-3.6 and OpenGL at the same time on Linux (with mesa, which uses llvm-3.4)
Hello there, tl;dr: Is it a known behaviour that using llvm-3.4 and llvm-3.6 at the same time in the same process (while llvm-3.6 is used from a linked shared library and llvm-3.4 is dlopen'ed - with a strange detail: Especially if -rdynamic is used when linking the program). If so, is there a workaround? If not, can it be fixed in llvm-3.6? Long story: I am writing a program that creates
2013 Apr 03
1
Documentation error in subsitute
Hi all, The documentation for substitute currently reads: Substitution takes place by examining each component of the parse tree as follows: If it is not a bound symbol in ?env?, it is unchanged. If it is a promise object, i.e., a formal argument to a function or explicitly created using ?delayedAssign()?, the expression slot of the promise replaces the symbol. If it is an ordinary variable,
2010 Nov 15
2
Trying to understand the search path and namespaces
Hi all, I'm trying to understand how the search path and namespaces interact. For example, take the devtools package which suggests the testthat package. Here's what the search path looks like after I load each of those packages: > library(devtools) > search() [1] ".GlobalEnv" "package:devtools" "package:stats" [4]
2011 Jul 11
4
Save generic plot to file (before rendering to device)
I am looking for a way to save a plot (graphics contents) to a file after the plot has been calculated but before it has been rendered. More specifically, assume that I made a plot that took a very long time to produce, I would like to save this plot to a generic file that I can later, on a different machine, render to either PDF, PNG, SVG using the usual R graphics devices, without recalculating
2011 Jul 11
4
Save generic plot to file (before rendering to device)
I am looking for a way to save a plot (graphics contents) to a file after the plot has been calculated but before it has been rendered. More specifically, assume that I made a plot that took a very long time to produce, I would like to save this plot to a generic file that I can later, on a different machine, render to either PDF, PNG, SVG using the usual R graphics devices, without recalculating
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
2012 Apr 24
2
load only one object from a .RData file
Hi list, Is there a way to load one specific object from a .RData file which contains multiple data objects?? Thanks, ...Tao
2009 Sep 04
3
Load a package without installing it
Hi all, When developing a package, it's often useful to be able to reload it, without re-installing, re-starting R and re-loading. To do this I've written a little script that inspects the package description and loads dependencies, data and code - http://gist.github.com/180883. It's obviously not very general (being tailored to my description files) and won't work for packages
2006 Dec 21
1
A problem with "copy()" in the svIO package
Hi R-users: When I type the following code in R, using the svIO package I got a problem only with the "latex" type option.(With "raw", "ascii" and "html" options, it works fine). x<-1:50 copy('x', type='latex', objname='x') Erro en file.info(fn <- c(...)) : argumento del nombre de archivo inv?lido Thank you for your help.
2010 Nov 24
1
diverting output from nested loops
Dear List, I have a series of nested loops with the structure shown below, and I am struggling to figure out how to divert output to folders created with dir.create() within the loops. What I need is for the output to end up as topNameK/subNameL/objNameM.pdf; what I get instead is a series of directories topNameK/, directories subNameL/, and files objNameM.pdf, all in the working directory. Any
2015 Oct 13
1
A where() functions that does what exists() does but return the environment when object lives?
On Tue, Oct 13, 2015 at 4:43 PM, Hadley Wickham <h.wickham at gmail.com> wrote: > Seems easy enough to write yourself: > > where <- function(x, env = parent.frame()) { > if (identical(env, emptyenv())) > return(NULL) > if (exists(x, envir = env, inherits = FALSE)) > return(env) > where(x, parent.env(env)) > } > > sample2 <-
2008 Feb 23
2
Aliasing a function
A simple way to alias a function is to do : g <- function(a = 1, b = 2, c = 3) a + b * c f <- function(...) g(...) but formals (etc) is no longer very helpful. Is there an easy way to programmatically create: f <- function(a=1, b=2, c=3) g(a=a, b=b, c=c) This comes up in ggplot2 where I alias many functions to hide the fact that I'm using proto in the background, and I'd like
2019 Nov 04
3
Puzzled about a new method for "[".
On 5/11/19 3:41 AM, Hadley Wickham wrote: > For what it's worth, I don't think this strategy can work in general, > because a class might have attributes that depend on its data/contents > (e.g. https://vctrs.r-lib.org/articles/s3-vector.html#cached-sum). I > don't think these are particularly common in practice, but it's > dangerous to assume that you can restore a
2015 Dec 10
6
How do I reliably and efficiently hash a function?
I?ve got the following scenario: I need to store information about an R function, and retrieve it at a later point. In other programming languages I?d implement this using a dictionary with the functions as keys. In R, I?d usually use `attr(f, 'some-name')`. However, for my purposes I do not want to use `attr` because the information that I want to store is an implementation detail that
2018 Mar 29
2
Base R examples that write to current working directory
Hi all, Given the recent CRAN push to prevent examples writing to the working directory, is there any interest in fixing base R examples that write to the working directory? A few candidates are the graphics devices, file.create(), writeBin(), writeChar(), write(), and saveRDS(). I'm sure there are many more. One way to catch these naughty examples would be to search for unlink() in
2008 May 18
3
R 2.70 + ps2pdf14
dear R graphics experts---if anyone is running the combination of R 2.7.0 and ghostscript (2.62), could you please run the following and let me know if you get the same strange symbol size that I do, or if there is something weird on my system? regards, /ivo pdf(file = "testhere.PDF", version="1.4", pointsize=14); plot(0, xlim=c(0,26), ylim=c(-1,4.5), type="n"