search for: fun2

Displaying 20 results from an estimated 78 matches for "fun2".

Did you mean: fun
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) { if (bb ==...
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 line debug...
2008 Oct 19
1
multivariate integral with ADAPT when the parameter is close to boundary
Dear All, There is one problem I encountered when I used ADAPT to compute some 2-D integral w.r.t beta density. For example, when I try to run the following comments: fun2<-function(theta){return(dbeta(theta[1],0.005,0.005)*dbeta(theta[2],0.005,0.005))} int.fun2<-adapt(ndim=2,lo = c(0,0), up = c(1,1),functn = fun2,eps = 1e-4) It seems it will take very long time to run. Acturally, I stopped the program after it was running for like 20 minutes. I thought this...
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(), localfun2())$p.value)...
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 unused argume...
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 examples similar...
2012 Dec 20
1
[LLVMdev] vmlx forwarding an cortex A9 question
...fference in term of performance, but on a more complex example disabling vmlx-forwarding leads to significant win in performance wise (10% speed-up). Does anyone can explain me what is the exact purpose of vmlx-forwarding option, and why it is enabled by default on cortex-A9. On attached file: llc fun2.ll -march=arm -mcpu=cortex-a9 -mattr=+neon -float-abi=soft -o fun2.s => vmla instruction not generated On attached file: llc fun2.ll -march=arm -mcpu=cortex-a9 -mattr=+neon,-vmlx-forwarding -float-abi=soft -o fun2.s => vmla instruction generated Thanks for your answers. Best Regards Seb ---...
2012 Nov 17
3
transform input argument (matrix) of function
...is easy with new matrix (see below), but my idea is to transform input argument (matrix) of function without any additional matrixes. Here is an example: fun1 <- function(xy) { xy <- cbind(xy[,1], xy[,2], xy[,1] + xy[,2]) return(xy) }   df1 <- matrix(c(1,2,3,1,2,3), ncol = 2) fun1(df1)   fun2 <- function(xy) { xy <- cbind(xy[,1], xy[,2], xy[,1] + xy[,2]) return(invisible(xy)) }   fun2(df1) df1 > should be      [,1] [,2] [,3] [1,]    1    1    2 [2,]    2    2    4 [3,]    3    3    6   Thanks to all for help, OV [[alternative HTML version deleted]]
2009 Oct 01
1
pass "..." to multiple sub-functions
...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-darwin8.11....
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]]
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 doesn't solve the problem, when l1=1.0e80. maybe i have to iterate between large values in integrate and large values in exp(l1) and then use the normal or the rescaled version? > l1<-10...
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, ...) { a=fun1(x=aa, y=5); # works well a=1+5+10=16 b=fun1(x=aa, ...); # works well b=1+4+8=13 y=0...
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), x3 = rno...
2009 Jun 16
1
ifelse(is.na), with function inside
...) 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), fun2(x)) : number of items to re...
2010 Aug 11
2
storing the results of an apply call
...-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 of &quot...
2002 Aug 01
6
update() can not find objects (PR#1861)
...by another function. Here is a R script to show the problem: ######## begin of the test script ########## fun1 <- function() { x <- matrix(rnorm(500), 20,25) y <- rnorm(20) oo <- lm(y~x) print("step 1") update(oo) print("first update success.") fun2(oo) } fun2 <- function(gg) { update(gg) print("second update success.") } fun1() ########### end of the test script ############# Here is the result of running this script: [1] "step 1" [1] "first update success." Error in eval(expr, envir, enclos) : Objec...
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...
2015 Feb 26
1
iterated lapply
...s 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 8 > >>> / On Feb 24, 2015, at 10:50 A...
2015 Feb 24
2
iterated lapply
> On Feb 24, 2015, at 10:50 AM, <luke-tierney at uiowa.edu> wrote: > > The documentation is not specific enough on the indented semantics in > this situation to consider this a bug. The original R-level > implementation of lapply was > > lapply <- function(X, FUN, ...) { > FUN <- match.fun(FUN) > if (!is.list(X)) > X <-
2011 Jun 09
3
Resources for utilizing multiple processors
...oblem another way. Can R temporarily use HD space to write calculations to instead of RAM? The second concern boils down to whether or not there is a way to split up dependent simulations. For example at iteration (t) I feed a(t-2) into FUN1 to generate a(t), then feed a(t), b(t-1) and c(t-1) into FUN2 to simulate b(t) and c(t). I'd love to have one core run FUN1 and another run FUN2, and better yet, a third to run all the pre-and post- processing tidbits! So if anyone has any suggestions as to a direction I can look into, it would be appreciated. Robin Jeffries MS, DrPH Candidate Departm...