search for: fun1

Displaying 20 results from an estimated 116 matches for "fun1".

Did you mean: fun
2012 Aug 30
1
How to modify the values of the parameters passing via ...
Dear Friends, Let's assume there are three parameters that were passed into fun1. In fun1, we need to modify one para but the remains need to be untouched. And then all parameters were passed into fun2. However, I have failed to achieve it. Please see the following code. ########################################## fun1 <-function(x, y, z=10) {x+y+z;} fun2 <-function(aa,...
2002 Sep 17
3
[LLVMdev] questions
...he type of simplstruct, should I use 'getType' member function like Inst.getType()? If I use that, I will get a PointerType, how can I use it? 2. Another question is that since we do the scalar replacement on each function. If the program look like this. struct s { int a; float b; } fun1( struct s *ps) { ps->a = 1; ps->b = 2; } main( ) { struct s mystru; fun1( &mystru ); } When we process the function 'fun1', should we change fun1 to something like fun1( int *a, float *b ) then change fun1(&mystru) in main to something like fun1( &mystru.a...
2011 Apr 07
2
Two functions as parametrs of a function.
Hi R users: I'm trying to make a function where two of the parameters are functions, but I don't know how to put each set of parameters for each function. What am I missing? I try this code: f2<-function(n=2,nsim=100,fun1=rnorm,par1=list(),fun2=rnorm,par2=list()){ force(fun1) force(fun2) force(n) p1<-unlist(par1) p2<-unlist(par2) force(p1) force(p2) localfun1 <- function() fun1(n, p1) localfun2 <- function() fun2(n, p2) vp<-replicate(nsim,t.test(localfun1(), loc...
2012 Nov 08
5
map two names into one
Thanks. Yes. Your approach can identify: Glaxy ace S 5830 and S 5830 Glaxy ace But you can not identify using same program: Iphone 4S 16 G Iphone 4S 16G How should I solve both in same time. Kind regards,Tammy [[alternative HTML version deleted]]
2006 Aug 09
3
objects and environments
Dear list, I have two functions created in the same environment, fun1 and fun2. fun2 is called by fun1, but fun2 should use an object which is created in fun1 fun1 <- function(x) { ifelse(somecondition, bb <- "o", bb <- "*") ## mymatrix is created, then myresult <- apply(mymatrix, 1, fun2) } fun2 <- function(idx) {...
2004 Mar 25
1
mlocal/mtrace inside a loop
Hello I need some help in figuring Bravington’s debugger out. Ok I have 2 functions, fun1 and fun2 saved in a ASCII file say filename is funs. Fun1 has a loop which calls fun2, fun2 has a loop which fails and I need to find out the value of the variables of the fun2 and fun1 loops at the specific iteration that fails. Both fun1 and fun2 loops will iterate thousands of times so line by l...
2017 Apr 30
1
`match.call` and dots substitution
I'm noticing some interesting behavior in `match.call` in some corner-ish cases that arise when you try to use `match.call` to match a "grandparent" function and there are dots involved: fun0 <- function(a, ...) fun1(...) fun1 <- function(b, ...) fun2() fun2 <- function() match.call( fun1, sys.call(sys.parent()), expand.dots=FALSE, envir=parent.frame(2) ) fun0(1, 2, 3) ## fun1(b = 2, ... = pairlist(3)) fun0((1), (2), (3)) # the parens...
2009 Oct 01
1
pass "..." to multiple sub-functions
Dear list, I know I have seen this discussed before but I haven't been successful in searching for "ellipsis", "dots", "..." in the archives. I would like to filter "..." arguments according to their name, and dispatch them to two sub-functions, say fun1 and fun2. I looked at lm() but it seemed more complicated than I need as it modifies the calling function among other things. What is the best approach for this? My current version presented below seems very awkward. Best regards, baptiste sessionInfo() R version 2.9.2 (2009-08-24) i386-apple-da...
2012 Nov 20
2
correct function formation in R
Dear list! ? I have question of?'correct function formation'. Which function (fun1 or fun2; see below) is written more correctly? Using ''structure'' as output or creating empty ''data.frame'' and then transform it as output? (fun1 and fun1 is just for illustration). ? Thanks a lot, OV ? code: input <- data.frame(x1 = rnorm(20), x2 = rnorm(20),...
2013 Jul 02
2
cache most-recent dispatch
Hi, S4 method dispatch can be very slow. Would it be reasonable to cache the most recent dispatch, anticipating the next invocation will be on the same type? This would be very helpful in loops. fun0 <- function(x) sapply(x, paste, collapse="+") fun1 <- function(x) { paste <- selectMethod(paste, class(x[[1]])) sapply(x, paste, collapse="+") } lst <- split(rep(LETTERS, 100), rep(1:1300, 2)) library(microbenchmark) microbenchmark(fun0(lst), times=10) ## Unit: milliseconds ## expr min...
2009 May 01
1
integrate with large parameters
Dear R-users, i have to integrate the following function `fun1` <- function (a, l1, l2) { exp(log(l1) * (a - 1) - l2 * lgamma(a)) } but if l1 is large, i get the "non-finite function value" error, so my idea is to rescale with exp(-l1) `fun2` <- function (a, l1, l2) { exp(log(l1) * (a - 1) - l2 * lgamma(a) - l1) } but it seems this does...
2006 Aug 16
1
Problem with the special argument '...' within a function
I'm not sure if this is what you want, but simply add ... to the list of arguments for fun1 and fun2 would eliminate the error. Andy From: Hans-Joerg Bibiko > > Dear all, > > I wrote some functions using the special argument '...'. OK, it works. > > But if I call such a function which also called such a > function, then I get an error message about unus...
2014 Jan 25
1
package NAMESPACE question
Hello, I'm building a package. My code is stored in foo.R. This code has two functions FUN1 and FUN2. FUN1 calls FUN2. FUN1 is listed in export() under the package NAMESPACE but NOT FUN2. After building the package when I call FUN1 is giving me an error that cannot find FUN2. I solved this by adding FUN2 in the export() NAMESPACE. However, what is puzzling me is that I have other example...
2009 Jun 16
1
ifelse(is.na), with function inside
...A, 3) and I would like to use is.na(a) function to get a vector like this: wy=(1,2,2,2,1,1,2) - you know, this vector create 1 or 2 depends on value in vector "a" This is my short code but something is wrong and I don't know what... for (i in 1:7){ a=c( NA, 3, 4, 4, NA, NA, 3) fun1=function(x){ x=1 print(x) } fun2=function(x){ x=2 print(x) } wy[i]<- ifelse(((is.na(a))), fun1(x), fun2(x)) } [1] 1 [1] 2 [1] 1 [1] 2 [1] 1 [1] 2 [1] 1 [1] 2 [1] 1 [1] 2 [1] 1 [1] 2 [1] 1 [1] 2 and I get a lots of warnings: Warning messages: 1: In wy[i] <- ifelse(((is.na(a))), fun1(x...
2010 Aug 11
2
storing the results of an apply call
Hi R-users, I have a function (myfun) that I want to apply to the rows of a matrix. Basically, "myfun" takes the values from the matrix ("exp.des"), which represent the different combinations of my experimental design, and pass them as arguments to some other functions (fun1 and fun2). As I want to replicate the results of fun1 and fun2 a certain number of time (e.g. 5), I have a for loop within myfun. I would like to store the results of each iteration of fun1 and fun2 in a separate matrix ("output") but I have some problems telling R which is the position...
2008 Nov 11
1
Retrieving x argument name from a trellis object in R 2.8.0
Dear all, let consider the following function: Fun1 <- function() { library(lattice) plot1 <- 1:10~1:10 pl1 <- xyplot(plot1) return(pl1$call$x) } In R 2.5.0 (or older version) we have > Fun1() plot1 but starting from R 2.5.1 until the latest R 2.8.0 we obtain instead > Fun1() NULL because pl1$call seems to be equal to x...
2001 Mar 08
2
surprising behavior of match.arg() (PR#872)
If a function needs to be passed as an argument to another function, default arguments to the function being passed are lost. Consider this example: fun1 <- function(x, A=c("power","constant")) { arg <- match.arg(A) cat(paste("A is:",paste(A,collapse=", "),"\narg is:",arg,"\n")) cat("formals:\n") print(formals()) 2*x } topfun <- function(x, Fun=fun1) { cat(&q...
2002 Sep 17
0
[LLVMdev] questions
...getType())) if (const StructType *ST = dyn_cast<StructType>(PT->getType())) // Work with ST... and it'll work. } 2. Another question is that since we do the scalar replacement } on each function. If the program look like this. } } struct s { } int a; } float b; } } } fun1( struct s *ps) { } ps->a = 1; } ps->b = 2; } } } main( ) } { } struct s mystru; } } fun1( &mystru ); } } } } When we process the function 'fun1', should we change fun1 to } something like } fun1( int *a, float *b ) } then change fun1(&mystru) in main to someth...
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", 10) ## should modify "x" ## now x should be 11, but only here and NOT globally! ... } I would like to appreciate any solution! Thanks in advance Meinhard Ploner
2015 Feb 26
1
iterated lapply
...ntics, yes. Each 'stream' of function calls is lazily capturing the last value of `i` on that core. Under Luke's proposed semantics (IIUC), the result would be the same (2,4,6,8) for both parallel and serial execution. This is what allows for 'drop-in' parallelism. >> fun1 <- function(c){function(i){c*i}} >> fun2 <- function(f) f(2) >> sapply(mclapply(1:4, fun1, mc.cores=1L), fun2) > [1] 8 8 8 8 >> sapply(mclapply(1:4, fun1, mc.cores=2L), fun2) > [1] 6 8 6 8 >> sapply(mclapply(1:4, fun1, mc.cores=4L), fun2) > [1] 2 4 6...