search for: meilstrup

Displaying 20 results from an estimated 26 matches for "meilstrup".

2011 Oct 22
2
Expanding rows of a data frame into multiple rows
The setup: I have a data frame where one column is in list mode, and each entry contains a vector of varying length. I want to expand this into a data frame with one row for each member of the list-mode column (the other values being replicated) For example, an example input and the desired output would be: input <- data.frame(site = 1:6, sector =
2009 Aug 21
4
Where to put source code?
I'm trying to move from Matlab to R, and I'm stuck even getting started. This sounds to me like the dumbest question in the world but... how does one put R source code in files? Over the last three days I've gone front to back through the Introduction to R and the R Language Definition, and while I'm excited that the language is so Lispish, none of what I read described how to
2013 Jul 07
2
The *tmp* variable
When complex assignments are performed, the R interpreter creates, then removes a special variable *tmp*. However, when byte compiling is enabled, it seems that a different mechanism for making compound assignments is used. Would it be possible to eliminate *tmp* from interpreted R code as well? It might be useful for a function to lock its own environment, and the appearance and disappearance of
2012 Apr 05
2
indexing data.frame columns
Consider the data.frame: df <- data.frame(A = c(1,4,2,6,7,3,6), B= c(3,7,2,7,3,5,4), C = c(2,7,5,2,7,4,5), index = c("A","B","A","C","B","B","C")) I want to select the column specified in 'index' for every row of 'df', to get goal <- c(1, 7, 2, 2, 3, 5, 5) This sounds a lot like the indexing-by-a-matrix
2018 Aug 13
2
substitute() on arguments in ellipsis ("dot dot dot")?
Interestingly, as.list(substitute(...())) also works. On Sun, Aug 12, 2018 at 1:16 PM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote: > On 12/08/2018 4:00 PM, Henrik Bengtsson wrote: >> >> Hi. For any number of *known* arguments, we can do: >> >> one <- function(a) list(a = substitute(a)) >> two <- function(a, b) list(a = substitute(a), b =
2018 Aug 13
1
substitute() on arguments in ellipsis ("dot dot dot")?
...10000 > # dots2(1 + 2, "a", rnorm(3), stop("bang!")) 1.81 2.10 2.47 2.21 > 2.34 1626 10000 > # dots3(1 + 2, "a", rnorm(3), stop("bang!")) 2.59 2.98 3.36 3.15 > 3.31 1037 10000 > > /Henrik > > On Mon, Aug 13, 2018 at 7:10 AM Peter Meilstrup > <peter.meilstrup at gmail.com> wrote: > > > > Interestingly, > > > > as.list(substitute(...())) > > > > also works. > > > > On Sun, Aug 12, 2018 at 1:16 PM, Duncan Murdoch > > <murdoch.duncan at gmail.com> wrote: > > &g...
2018 Jan 03
3
Coping with non-standard evaluation in R program analysis
Hello R experts, I plan to develop a tool for dynamic analysis of R programs. I would like to trace function calls at runtime, capturing argument and return values. Following a suggestion made some time ago on this list, my high-level implementation strategy is to rewrite the AST, augmenting call expressions with pre-call and post-call shims to capture the arguments and return value,
2018 Aug 13
0
substitute() on arguments in ellipsis ("dot dot dot")?
...ot;)) 2.14 2.45 3.04 2.58 2.73 1110 10000 # dots2(1 + 2, "a", rnorm(3), stop("bang!")) 1.81 2.10 2.47 2.21 2.34 1626 10000 # dots3(1 + 2, "a", rnorm(3), stop("bang!")) 2.59 2.98 3.36 3.15 3.31 1037 10000 /Henrik On Mon, Aug 13, 2018 at 7:10 AM Peter Meilstrup <peter.meilstrup at gmail.com> wrote: > > Interestingly, > > as.list(substitute(...())) > > also works. > > On Sun, Aug 12, 2018 at 1:16 PM, Duncan Murdoch > <murdoch.duncan at gmail.com> wrote: > > On 12/08/2018 4:00 PM, Henrik Bengtsson wrote: >...
2018 Jan 04
0
Coping with non-standard evaluation in R program analysis
...analyzing promises and generating execution traces within the R VM. This is available in https://github.com/PRL-PRG/R-dyntrace Aviral and Konrad are the contacts there. Best, jan Jan Vitek, Professor Computer Science, Northeastern University > On Jan 3, 2018, at 7:18 PM, Peter Meilstrup <peter.meilstrup at gmail.com> wrote: > > For 2), it is not exposed in R's standard library but it is exposed in > the Rinternals API. A promise that is forced in normal evaluation will > have PRENV set to NULL. > > Peter > > On Tue, Jan 2, 2018 at 4:19 PM, Evan...
2009 Sep 03
5
abind, but on lists?
I'm trying to massage some data from Matlab into R. The matlab file has a "struct array" which when imported into R using the R.matlab package, becomes an R list with 3+ dimensions, the first of which corresponds to the structure fields, with corresponding row names, and the second and third+ dimensions correspond to the dimensions of the original struct array (as matlab
2012 Oct 04
2
How to build a list with missing values? What is missing, anyway?
This is tangentially related to Hadley's question. Suppose I'm building a function programmatically; I have assembled an expression for the body and I know the names of the arguments it wants to take. Suppose I have some convenience function such that writing make_function(alist(a=, b=), quote(a+b), environment()) is equivalent to writing function(a,b) a+b So how do I make the
2013 Jan 23
1
Arguments passing through dot-dot-dot lose ability to check for missing()?
Hi R-devel. Is the following behavior in g1() and h1() expected? It seems to make "..." arguments work slightly differently from named arguments. #missing() has the property that it looks "up the chain" #for example, "z" can be missing in f3 even if #that argument did have a name ("y") in f2 f1 <- function(x, ...) { cat("In f1, missing(x) is
2018 Feb 17
2
Problem installing libxml2 under Homebrew
i am trying to install xml2 from CRAN, and it is throwing an error that it cannot find the libxml2 library configuration. The thing is that pkg-config seems to be set up correctly: $ echo $PKG_CONFIG_PATH :/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig $ pkg-config --cflags --libs libxml-2.0 -I/usr/local/Cellar/libxml2/2.9.7/include/libxml2
2011 Oct 14
1
pgfSweave-example not compiling
I'm trying to get pgfSweave up and running. Hopefully I can get it working from within LyX, but first I'm just trying to get the simplest possible thing (compiling one of the example files in the pgfSweave package) to work. I'm using the example that comes in the pgfSweave package unmodified, but for reference I copied it to: http://pastebin.com/tW4RL6fs Configuration: R version
2009 Nov 10
1
Is it possible to detect whether running as Rscript?
I would like to write a block of code that runs when a script is being run from Rscript, but not to run if the same file is being source()d, or submitted via ESS, etc. As a gloss I would like to write a file that looks somewhat like: #!/usr/bin/env Rscript my.func <- function(...) { #do something... } if ( #is.running.Rscript# ) { do.call(my.func, commandArgs(trailingOnly=TRUE)) }
2012 Mar 17
0
tryCatch interferes with traceback(), debugger(), dump.frames()....
...a language feature in the first place - to propagate out debugging information while allowing you to clean up. So I am confused why tryCatch ends up obscuring the debugging information. How can I use it in a way that dump.frames() or retrace() or some equivalent points me to the right spot? Peter Meilstrup [[alternative HTML version deleted]]
2013 Jul 08
1
does subset.data.frame need to accept extra arguments?
The formal list for subset.data.frame accepts a "..." > args(subset.data.frame) function (x, subset, select, drop = FALSE, ...) NULL But it appears that subset.data.frame does not actually use the "..." or pass it along: > "..." %in% all.names(body(subset.data.frame)) [1] FALSE Is there any reason why subset.data.frame needs to accept extra, unused
2013 Sep 05
1
Why does duplicate() make deep copies?
Some experimentation with the below function should convince you that the runtime of the bit inside sys.time is proportional to size*number*times. I think it should only be proportional to number*times. The function is only manipulating a list of references to vectors and not trying to make changes to the vectors themselves. overcopying <- function(size, number, times) { #Make a list of
2013 May 08
1
Dependencies of Imports not attached?
Encountered an error in scripting, which can be reproduced using Rscript as follows: $ Rscript -e "library(httr); handle('http://cran.r-project.org')" Error in getCurlHandle(cookiefile = cookie_path, .defaults = list()) : could not find function "getClass" Calls: handle -> getCurlHandle or by starting R without the methods package attached: $
2013 Aug 18
1
How does R_UnboundValue and removing variables work?
Reading "R Internals" made me believe that R_UnboundValue was a placeholder that would be skipped over in variable lookup. viz. the section of R Internals "Hash tables" says "items are not actually deleted but have their value set to R_UnboundValue.", which seems to align with what I read in envir.c. So, I reasoned, if I have a function that returns R_UnboundValue,