search for: fn2

Displaying 20 results from an estimated 50 matches for "fn2".

Did you mean: fn
2010 Jul 05
3
data.frame: adding a column that is based on ranges of values in another column
...ue in "Date" falls within the first fortnight (f.n1) then the value of the new "Fortnight" column would be "FN1", and if the value of the "Date" column falls within the second fortnight (f.n2), then the value of the "Fortnight" column would be "FN2", and so on. The end result should look like: X Y Date Fortnight 1 114.5508 47.14094 2009-01-01 FN1 2 114.6468 46.98874 2009-01-03 FN1 3 114.6596 46.91235 2009-01-05 FN1 4 114.6957 46.88265 2009-01-10 FN1 5 114.6828 46.80584 2009-01-14...
2013 Jan 01
1
Behavior or as.environment in function arguments/call (and force() behaviors...)
...so 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. Either way Fn1() below can't really be explained. Major question is what in the world is Fn1 doing, and why is Fn2 not equal to Fn3? [ Fn3/Fn4 are doing what I want. ] Fn1 <- function(x="test",pos=-1,env=as.environment(pos)) { ls(env) } Fn2 <- function(x="test",pos=-1,env=as.environment(pos)) { force(env) ls(env) } Fn3 <- function(x="test",pos=-1,env=as.environment(pos...
2009 Feb 04
0
Problem using option packeg with new R version (PR#13498)
...593536> > n<-nrow(X)> p<-ncol(X)> n[1] 5> p[1] 6> > v<-rep(0,p-1)> v[1] 0 0 0 0 0> > fn1<-function(v) {+ a<-sum(v*v)+ u<-v/sqrt(1+a)+ b<-sum(u*u)+ u[length(v)+1]<-sqrt(1+b)+ c<<- X %*% u # also I try c<- X %*% u+ fn1<- - optim(c(0,1),fn2,NULL,method="BFGS",c)$value+ }> > > fn2<-function(par){+ fn2<- -length(c)*log(par[2])+sum(log(par[2]*par[2]+(c-par[1])*(c-par[1])))+ }> optim(v,fn1,NULL,method="BFGS",X)Error in fn(par, ...) : unused argument(s) (c(-0.277693546148993, -0.091468312551809, -0....
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. JS fn1 <- function(model,...
2005 Feb 01
2
assign connections automatically
...etup for this example > x<-1:20 > y<-20:40 > z<-40:60 > write(x, file="testx.txt") > write(y, file="testy.txt") > write(z, file="testz.txt") > inConnect <- function(){ + fn <- dir(pattern="*.txt") # grab only *.txt files + fn2 <- gsub('.txt', "", fn) # removes the '.txt' from each string + for(i in 1:length(fn)) + assign((fn2[[i]]),file(fn[i], open="r")) + } > showConnections() #currently, no connections description class mode text isopen can read can write > inConnect(...
2017 Aug 04
3
[RFC][InlineCost] Modeling JumpThreading (or similar) in inline cost model
...l, 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, unsigned char changed) { if (a_ptr && b_ptr && a_ptr->idx == b_ptr->idx) { if (!changed && dst_ptr && dst_ptr->idx == a_ptr->idx) { /* Do something */...
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 supplying > onl...
2016 Dec 15
2
distinct DISubprograms hindering sharing inlined subprogram descriptions
...sorry. Old old way: first.ll: CU1 -> {fn1_SP -> @fn1, inl_SP -> @inl, ... } @fn1 ... @inl ... Resulting DWARF: compile_unit CU1 subprogram fn1 high/low pc, etc subprogram inl high/low pc, etc second.ll: CU2 -> {inl_SP2 -> @inl, SP2 -> @fn2, ... } @inl ... @fn2 ... Resulting DWARF: compile_unit CU2 subprogram inl high/low pc, etc subprogram fn2 high/low pc, etc link first.ll + second.ll: CU1 -> {fn1_SP -> @fn1, inl_SP -> @inl, ... } CU2 -> {inl_SP2 -> null, SP2 -> @fn2, ......
2008 Apr 17
1
Help with using 'get' function and variable scope
...time w/understanding R's get function, and would appreciate any help with this. Specifically, I'm using a for loop to call a function. I'd like the function to have access to the variable being incremented in the for-loop, i.e. t.fn <- function() return( get( "i" ) ) t.fn2 <- function() { for ( i in 1:5 ) cat( t.fn(), "\n" ) } However, I keep getting err msg's from the 'get' function about how it can't find the 'i' variable. I've tried various combinations w/in the get fn, i.e. passing inherits=T (should be the default...
2016 Dec 16
0
distinct DISubprograms hindering sharing inlined subprogram descriptions
...> @fn1, inl_SP -> @inl, ... } > @fn1 ... > @inl ... > Resulting DWARF: > compile_unit CU1 > subprogram fn1 > high/low pc, etc > subprogram inl > high/low pc, etc > > second.ll: > CU2 -> {inl_SP2 -> @inl, SP2 -> @fn2, ... } > @inl ... > @fn2 ... > Resulting DWARF: > compile_unit CU2 > subprogram inl > high/low pc, etc > subprogram fn2 > high/low pc, etc > > link first.ll + second.ll: > CU1 -> {fn1_SP -> @fn1, inl_SP -> @inl, ... }...
2016 Dec 16
2
distinct DISubprograms hindering sharing inlined subprogram descriptions
...> @fn1, inl_SP -> @inl, ... } > @fn1 ... > @inl ... > Resulting DWARF: > compile_unit CU1 > subprogram fn1 > high/low pc, etc > subprogram inl > high/low pc, etc > > second.ll: > CU2 -> {inl_SP2 -> @inl, SP2 -> @fn2, ... } > @inl ... > @fn2 ... > Resulting DWARF: > compile_unit CU2 > subprogram inl > high/low pc, etc > subprogram fn2 > high/low pc, etc > > link first.ll + second.ll: > CU1 -> {fn1_SP -> @fn1, inl_SP -> @inl, ... }...
2017 Aug 04
4
[RFC][InlineCost] Modeling JumpThreading (or similar) in inline cost model
...; 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 (SPEC2017/gcc, ironically), there are multiple calls to fn2 and only one of them has the property that the 1st and 2nd argument are the same (as is shown in my pseudo code). Internally, we have another developer, Matt Simpson, working on a function specialization patch that might be of value here. Specifically, you could clone fn2 based on the fact that...
2016 Dec 16
0
distinct DISubprograms hindering sharing inlined subprogram descriptions
...@fn1 ... >> @inl ... >> Resulting DWARF: >> compile_unit CU1 >> subprogram fn1 >> high/low pc, etc >> subprogram inl >> high/low pc, etc >> >> second.ll: >> CU2 -> {inl_SP2 -> @inl, SP2 -> @fn2, ... } >> @inl ... >> @fn2 ... >> Resulting DWARF: >> compile_unit CU2 >> subprogram inl >> high/low pc, etc >> subprogram fn2 >> high/low pc, etc >> >> link first.ll + second.ll: >> CU1 ->...
2008 Apr 23
3
[LLVMdev] Compile units in debugging intrinsics / globals
...ll are defined in the same source file. If data or a function is defined in an included file then they appear to be in a different compile unit. Suppose I have the following source: file1: #include "file2" #include "file3" int fn1(void) ... file2: int a; file3: int fn2(void) ... then fn1, along with all the base types etc appear to be in compile unit "file1", the variable a appears to be in compile unit "file2" (and there are no basic types in file2, so int is not defined), and fn2 appears to be in compile unit "file3". My dwarf r...
2008 Apr 24
0
[LLVMdev] Compile units in debugging intrinsics / globals
Hi, > Suppose I have the following source: > > file1: > #include "file2" > #include "file3" > int fn1(void) ... > > file2: > int a; > > file3: > int fn2(void) ... > > then fn1, along with all the base types etc appear to be in compile unit > "file1", the variable a appears to be in compile unit "file2" (and there are > no basic types in file2, so int is not defined), and fn2 appears to be in > compile unit &quo...
2017 Aug 07
3
[RFC][InlineCost] Modeling JumpThreading (or similar) in inline cost model
...esn'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 (SPEC2017/gcc, ironically), there are multiple calls to fn2 and only one of them has the property that the 1st and 2nd argument are the same (as is shown in my pseudo code). Internally, we have another developer, Matt Simpson, working on a function specialization patch that might be of value here. Specifically, you could clone fn2 based on the fact that a...
2011 May 09
2
Vectorizing a function: what does it mean?
...n such a way so that if input(s) are vector then this function will also return a vector output (without having any extra effort like use of 'for' loop etc.) Is this understanding correct? Here I have tried 2 essentially similar functions: > fn1 <- function(x,y,z) return(x+y+z) > fn2 <- Vectorize(function(x,y,z) return(x+y+z), SIMPLIFY=TRUE) > fn1(1:3, 4:6,5) [1] 10 12 14 > fn2(1:3, 4:6,5) [1] 10 12 14 You see that, fn1() and fn2() is giving same answer (vectorized?) despite of the fact that fn1() is not wrapped within Vectorize() function. Therefore I want to know:...
2006 Oct 27
1
Using data and subset arguments in user-defined functions
...unction(expr, data) { x <- eval(substitute(expr), envir=data) return(mean(x)) } eg.fn(a,data) I've tried various approaches to add a subset argument to the example above, but no luck. I'm looking for something like the following (but that works!) eg.fn2 <- function(expr, data, subset) { data <- subset(data,subset) x <- eval(substitute(expr), envir=data) return(mean(x)) } eg.fn2(a, data, subset=a>3) This returns the error: "Error in eg.fn2(a, data, subset = a > 3) :...
2005 Dec 29
1
S4 classes: referencing slots with other slots
...an reuse a slot. That is, for various reasons it would be nice to be able to do something like: setClass("fooWfcn", representation(dat1="vector", dat2="vector", fn1="function", fn2="function"), prototype=list(dat1=0:10, dat2=10:20, fn1=function(x) { return(x - mean(self.dat1)) }, fn2=function() { mean(self.dat2) })) and in the context of foo <- new("fooWfcn") have self.dat2 refer to foo at dat2, etc (I.e. in...
2016 Dec 15
0
distinct DISubprograms hindering sharing inlined subprogram descriptions
On Thu, Dec 15, 2016 at 11:38 AM, David Blaikie <dblaikie at gmail.com> wrote: > > > On Thu, Dec 15, 2016 at 11:26 AM Teresa Johnson <tejohnson at google.com> > wrote: > >> Trying to wrap my brain around this, so a few questions below. =) >> > > Sure thing - sorry, did assume a bit too much arcane context here. > > >> >> On Thu, Dec