similar to: formal vs. passed args: parent.frame() behavior.

Displaying 20 results from an estimated 40000 matches similar to: "formal vs. passed args: parent.frame() behavior."

2013 Jan 01
1
Behavior or as.environment in function arguments/call (and force() behaviors...)
Happy 2013! Can someone with more knowledge of edge case scoping/eval rules explain what is happening below? Happens in all the versions of R I have on hand. Behavior itself is confusing, but ?as.environment also provides no clue. The term used in that doc is 'search list', which is ambiguous, but the see also section mentions search(), so I would *think* that is what is intended.
2011 Aug 30
2
Non-GPL C (or R) inside of a package
R-devel, I am interested in creating a package that requires non-GPL'd (commercial) C code to work. In essence it is a single .c file with no use of R headers (all .C callable functions). For example's sake: 1 #include <stdio.h> 2 3 void test (int *a) { 4 *a = 101; 5 } The package isn't destined for CRAN, and I realize that this isn't R-legal, but looking for
2016 Jul 27
2
Model object, when generated in a function, saves entire environment when saved
Another solution is to only save the parts of the model object that interest you. As long as they don't include the formula (which is what drags along the environment it was created in), you will save space. E.g., tfun2 <- function(subset) { junk <- 1:1e6 list(subset=subset, lm(Sepal.Length ~ Sepal.Width, data=iris, subset=subset)$coef) } saveSize(tfun2(1:4)) #[1] 152 Bill
2011 Mar 18
1
[Patch suggestion] Adding 3rd arg to tempfile() to set extension
The other day I was working on an example which used tempfile() to create file for use by the graphics device. And while I love tempfile()---as it is portable and clever and the files get cleaned by R and all that---I noticed one missing feature I would like to see: beside a starting name pattern, and an optional directory, an 'file extension' argument would be nice to have. As e.g. in
2020 Jan 29
2
Model object, when generated in a function, saves entire environment when saved
Reviving an old thread. I haven't noticed this be a problem for a while when saving RDS's which is great. However, I noticed the problem again when saving `qs` files (https://github.com/traversc/qs) which is an RDS replacement with a fast serialization / compression system. I'd like to get an idea of what change was made within R to address this issue for `saveRDS`. My thought is that
2010 Nov 11
1
Problem with system2(), directing STDERR to a file
According to ?system2, I should be able to direct the output of STDERR to a file by giving the filename as a character vector to the "stderr" argument. But here is what happens. Given a ruby script test.rb (with its executable bit set): #!/usr/bin/env ruby STDOUT.puts "stdout" STDERR.puts "stderr" And the following R code: > t <- tempfile() > res <-
2000 Dec 20
1
unlink() is not synchronized with existing connections (PR#783)
> # creating a file > cat("sddfasdf", file="tempfile") > showConnections() class description mode text isopen can read can write > con <- file("tempfile", "r") > readLines(con) [1] "sddfasdf" Warning message: incomplete final line in: readLines(con, n, ok) > showConnections() class description mode text isopen
2011 Oct 18
2
Remote environments, calling functions
Hi there, I'm trying to do something like a migration of an R program. I've got a function and some variables in an interactive-session: r <- .5 ## estimatePi references r estimatePi <- function(seed) { set.seed(seed) numDraws <- 1e+05 x <- runif(numDraws, min = -r, max = r) y <- runif(numDraws, min = -r, max = r) inCircle <- ifelse((x^2 + y^2)^0.5
2013 Mar 19
1
source, sys.source and error line numbers
Hi, is there a way to retrieve the line number of where en error occurred when sourcing a file in a tryCatch statement? Is it stored somewhere accessible? It is not found in the error object. Consider the following code/output and note the difference in the traceback between source (has line number) and sys.source (has no line number). Thank you, Renaud ######## # code ######## codefile <-
2001 Jul 27
2
Seemingly bizarre behavior in R CMD check
Maybe someone can help shed some light on an odd and repeatedly irritating error I noticed when running the check Perl script on my R 1.3 project. In following it line by line, I traced my problem down to the code/documentation matching within check, the most recent version of which seems to verify proper .Rd formatting by means of R's codoc and undoc functions. Under R --vanilla, those two
2011 Jul 22
1
reg.finalizer and connection gc -- which runs when (and why)?
With this set-up options(warn = 1) tf <- tempfile() finalizer <- function(obj) { message("finalizer") close(obj$f) } this code works ev <- new.env() ev$f <- file(tf, "w") reg.finalizer(ev, finalizer) rm(ev) gc() whereas this (reversing the order of file() and reg.finalizer()) ev <- new.env() reg.finalizer(ev, finalizer) ev$f <- file(tf,
2011 Oct 18
9
readRDS and saveRDS
Hi all, Is there any chance that readRDS and saveRDS might one day become read.rds and write.rds? That would make them more consistent with the other reading and writing functions. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/
2011 Feb 04
1
matching symbols to objects
Hello, I'm trying to access an object, given only its name as a symbol. I cannot figure out how to proceed. Suppose I call substitute( ) on the expression 'x + 2': > parse.tree <- substitute(x + 2); The constituents of parse.tree are of type symbol and numeric: > str(parse.tree[[1]]) symbol + > str(parse.tree[[2]]) symbol x > str(parse.tree[[3]]) num 2 Suppose
2011 Mar 11
1
hook for when R quits
Hi, Is there any way that a package can listen for when R quits? The Qt stuff is hooking into platform-specific event loops and when those die unexpectedly (from the perspective of Qt), it aborts, causing an annoying error dialog. If we could catch when R is killed, we could cleanup, like we do with .onUnload. Thanks, Michael [[alternative HTML version deleted]]
2012 Feb 10
1
which R package is used for browsing web pages through coding
i know RCurl pakage to retrieve web content,it has limited use, i want interactive package like (in perl--->Mechanize, In java--->Watij,Prowser,HTMLunit,HTTPunit, in Ruby---->Watir ,etc) this modules/packages opens appropriate browser,which can create queries,retrieves output, clicks buttons, fill up form automatically,searches keyword in search engine, Downloads many items from
2001 Nov 01
3
Lost backslashes in parse()
I'm comparing R-1.3.0 on Solaris 2.6 to R-1.3.1 on WindowsNT. The following 5-line script returns TRUE on Unix but FALSE on NT: fnam <- tempfile() file.create(fnam) txt <- paste("file.exists(\"", fnam, "\")", sep="") expr <- parse(text=txt) eval(expr) The issue seems to be that backslashes get lost in the parsing. A workaround is to change
2016 Dec 12
2
why does parent.frame() cycle when called from inside capture.output()?
Hello R devel/help, I ran into this strange behavior: # showstack is supposed to walk through the stack of parent # environments when it is called: showstack = function() { env = environment() for(i in 1:12) { env = do.call(parent.frame, list(), env=env) print(env) } } # a simple chain of functions: g3=function(t) showstack()
2016 Dec 12
2
why does parent.frame() cycle when called from inside capture.output()?
Hello R devel/help, I ran into this strange behavior: # showstack is supposed to walk through the stack of parent # environments when it is called: showstack = function() { env = environment() for(i in 1:12) { env = do.call(parent.frame, list(), env=env) print(env) } } # a simple chain of functions: g3=function(t) showstack()
2008 Sep 09
2
make methods work in lapply - remove lapply's environment
I've defined my own version of summary.default, that gives a better summary for highly skewed vectors. If I call summary(x) the method is used. If I call summary(data.frame(x)) the method is not used. I've traced this to lapply; this uses the new method: lapply(list(x), function(x) summary(x)) and this does not: lapply(list(x), summary) If I make a copy of lapply, WITHOUT the
2010 Jun 17
2
tempfile problem
G'day all, The documentation for tempfile states : "The names are very likely to be unique among calls to tempfile in an R session and across simultaneous R sessions. The filenames are guaranteed not to be currently in use." My problem I think relates to the second part of the sentence, which is the guarantee... and it is being met ... but I need to save the files as .png files,