Displaying 20 results from an estimated 10000 matches similar to: "Help with using 'get' function and variable scope"
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.
2017 Aug 04
3
[RFC][InlineCost] Modeling JumpThreading (or similar) in inline cost model
All,
I'm working on an improvement to the inline cost model, but I'm unsure
how to proceed. Let me begin by first describing the problem I'm trying
to solve. Consider the following pseudo C code:
*typedef struct element {
unsigned idx;
} element_t;
*
*static inline
unsigned char fn2 (element_t *dst_ptr, const element_t *a_ptr,
const element_t *b_ptr,
2017 Aug 04
4
[RFC][InlineCost] Modeling JumpThreading (or similar) in inline cost model
On 8/4/2017 2:06 PM, Daniel Berlin wrote:
> A few notes:
> I'm a bit surprised IPO copy/constant propagation doesn't get this
> case, but i didn't look if the lattice supports variables.
> In particular, in your example, given no other call sites, it should
> eliminate the dead code.
> (In a real program, it may require cloning).
In the actual program
2017 Aug 07
3
[RFC][InlineCost] Modeling JumpThreading (or similar) in inline cost model
Hi,
Coincidentally I've been working to optimize this same case last week. I was struggling a bit to determine where to put this functionality and eventually went for the pragmatic approach of creating an experimental pass. Probably not the eventual solution, but it may provide some useful input to the discussion here.
Basically, I experimented with a 'pre-inlining-transform' pass
2008 Aug 25
0
[LLVMdev] Proposal : Function Notes
On Aug 22, 2008, at 4:40 PM, Devang Patel wrote:
> The LLVM passes are responsible to take appropriate actions based on
> Function
> Notes associated with function definition. For example,
>
> define void @fn1() notes("opt-size=1") { ... }
>
> The function fn1() is being optimized for size without losing
> significant
> performance. The inliner will
2010 Jul 05
3
data.frame: adding a column that is based on ranges of values in another column
Dear List,
I've been looking tirelessly for a solution to this dilemma but without success. Perhaps someone has an idea that will guide me in the right direction.
Suppose I have the following data.frame:
DF = data.frame(X = c(114.5508, 114.6468, 114.6596, 114.6957, 114.6828, 114.8903, 114.9519, 114.8842,
114.8579, 114.8489), Y = c(47.14094, 46.98874, 46.91235, 46.88265, 46.80584, 46.67022,
2005 Feb 01
2
assign connections automatically
Hi all,
I am trying to create a function that will open connections to all
files of
one type within the working directory.
I've got the function to open the connections, but I am having a
bugger of a
time trying to get these connections named as objects in the workspace.
I am at the point where I can do it outside of the function, but not
inside, using assign. I'm sure I'm
2008 Aug 22
10
[LLVMdev] Proposal : Function Notes
Here is a proposal that I mentioned sometime ago. Any
thoughts,comments or
suggestions on this proposal would be appreciated.
-
Devang
//
=
=
=----------------------------------------------------------------------
===//
// Function Notes (or Traits)
//
=
=
=----------------------------------------------------------------------
===//
This document describes the
2011 May 07
1
Evaluating a multivariable function XXXX
>
> Hello everyone,
>
> I have the following R code for a multivariable function:
>
>
> > fn2<-function(x,y,z){(y+2*z)/(5*y-x*z)}
> >
> > fn2(-5,-2,3)
> [1] 0.8
>
>
>
> No problems.
>
> ===
>
> If, however, I call the function using a vector substitution for the
> arguments, R sees this as 3 separate calls to the function while
2006 Oct 27
1
Using data and subset arguments in user-defined functions
Dear list,
A while ago, I posted a question asking how to use data or subset
arguments in a user-defined function. Duncan Murdoch suggested the
following solution in the context of a data argument:
data <- data.frame(a=c(1:10),b=c(1:10))
eg.fn <- function(expr, data) {
x <- eval(substitute(expr), envir=data)
return(mean(x))
}
eg.fn(a,data)
I've
2009 Mar 23
4
newton method
Hi R-users,
Does R has a topic on newton's method?
Thank you for the info.
2017 Aug 07
2
[RFC][InlineCost] Modeling JumpThreading (or similar) in inline cost model
On 8/7/2017 1:02 PM, Daniel Berlin wrote:
> Can someone fill me in on the issue with the dominator tree,
> precisely, during inlining?
> We now have the capability of quickly keeping it up to date without
> too much trouble (it may require pushing it through a bunch of places,
> but the actual changes to do should be easy).
If I'm not mistaken (which I very well could be
2013 Mar 22
2
A question on function return
Hello again,
Let say I have following user defined function:
fn <- function(x, y) {
Vec1 <- letters[1:6]
Vec2 <- 1:5
return(list(ifelse(x > 0, Vec1, NA), ifelse(y > 0, Vec2, NA)))
}
Now I have following calculation:
> fn(-3, -3)
[[1]]
[1] NA
[[2]]
[1] NA
> fn(3, -3)
[[1]]
[1] "a"
[[2]]
[1] NA
Here I can not understand why in the second case, I get
2013 Mar 16
1
Question on assignment
Hello again, I was trying to understand how I can assign variables in
some other Environments which is different from that variable's
original Environment. Let say I have following nested functions:
fn <- function(x) {
x1 <- function(y = x) {
y1 <- log(y)
y2 <- y^2
return(0)
}
### I want the variable 'y1' is available here. WITHOUT using the
return()
2008 Jan 03
2
Suggestion on how to make permanent changes to a single object in a list?
specifically, imagine we have:
fooStack <- list()
for ( i in 1:5 )
fooStack[[i]] <- list()
and we have a function:
fooModifier <- function( foo ) {
foo$bar <- "bar"
}
then, if we invoke fooModifier, i.e.:
fooModifier( fooStack[[ 1 ]] )
the $bar elt is only set in the scope of the function, and if we use the
2008 Aug 25
2
[LLVMdev] Proposal : Function Notes
On Aug 25, 2008, at 3:24 PM, Nick Kledzik wrote:
>
> On Aug 22, 2008, at 4:40 PM, Devang Patel wrote:
>
>> The LLVM passes are responsible to take appropriate actions based
>> on Function
>> Notes associated with function definition. For example,
>>
>> define void @fn1() notes("opt-size=1") { ... }
>>
>> The function fn1() is being
2001 Apr 27
3
nls question
I have a question about passing arguments to the function f that nlm
minimizes.
I have no problems if I do this:
x<-seq(0,1,.1)
y<-1.1*x + (1-1.1) + rnorm(length(x),0,.1)
fn<-function(p)
{
yhat<-p*x+(1-p)
sum((y-yhat)^2)
}
out<-nlm(fn,p=1.5,hessian=TRUE)
But I would like to define
fn<-function(x,y,p)
{
yhat<-p*x+(1-p)
sum((y-yhat)^2)
}
so
2006 Jul 17
10
String manipulation and formatting
I'm trying to write a simple function that does the following:
[command] xify(5.2)
[output] XXX.XX
[command] xify(3)
[output] XXX
Any simple solutions (without using python/perl/unix script/...)?
Thanks,
Saghir
---------------------------------------------------------
Legal Notice: This electronic mail and its attachments are i...{{dropped}}
2006 Jun 22
2
weights in lm, glm (PR#9023)
Full_Name: James Signorovitch
Version: 2.2.1
OS: WinXP
Submission from: (NULL) (134.174.182.203)
In the code below, fn1() and fn2() fail with the messages given in the comments.
Strangely, fn2() fails for all data sets I've tried except for those with 100
rows.
The same errors occur if glm() is used in place of lm(), or if R 2.1.1 is used
on a unix system. Thanks for looking into this.
2011 May 07
1
Printing a title for an object in the console when writing a function XXXX
Hello everyone,
What is the best way to have R print a title and then skip a line (both
without the [1] line preffix) when writing a function that prints an object
(to the console)? Simplified example:
fn3<-function(x,y){
c1<-cov(x,y)
print(c1)}
data1<-data.frame(age=rnorm(50),weight=rnorm(50))
attach(data1)
fn3(age,weight)
=====
How do I have R print a nicely formatted title