search for: cfun

Displaying 20 results from an estimated 20 matches for "cfun".

Did you mean: cfu
2018 Oct 16
2
invisible functions
...uot;n/G", "n/G2"), ?????????????????????????????? influence=0, ranks=FALSE, timefix=TRUE) { ??? Call <- match.call() ??? . ??? . ??? . ??? cargs <- c("ymin", "ymax","influence", "ranks", "timewt", "timefix") ??? cfun <- Call[c(1, match(cargs, names(Call), nomatch=0))] ??? cfun[[1]] <- quote(cord.work) ??? cfun$reverse <- TRUE ??? rval <- eval(cfun, parent.frame()) This worked fine in my not-in-a-namespace test bed, but then fails when packaged up for real: the code can't find the helper fun...
2018 Oct 16
0
invisible functions
...????????????????????????????? influence=0, ranks=FALSE, timefix=TRUE) { > ??? Call <- match.call() > ??? . > ??? . > ??? . > ??? cargs <- c("ymin", "ymax","influence", "ranks", "timewt", "timefix") > ??? cfun <- Call[c(1, match(cargs, names(Call), nomatch=0))] > ??? cfun[[1]] <- quote(cord.work) > ??? cfun$reverse <- TRUE > ??? rval <- eval(cfun, parent.frame()) > > This worked fine in my not-in-a-namespace test bed, but then fails when packaged up for > real: the co...
2015 Jun 03
2
Problem with shared library and lapack under windows
Hi all, I have a C function, say Cfun, that calls Lapack's DGEMM routine and I need to create a shared library to use Cfun inside R. The C file is the following #include<stdio.h> #include<R.h> #include<R_ext/Lapack.h> void Cfun(double *res, double *X, int *n, int *q) { char *ptr_TRANSA, TRANSA='T', *pt...
2017 Mar 31
2
How to write the same things as `opt` command in C++ API
...ivateLinkage, "a", module.get()); /// @brief Create a function (define i32 b()) llvm::Function *bFun = llvm::Function::Create(commonfuncType, llvm::Function::PrivateLinkage, "b", module.get()); /// @brief Create a function (define i32 c()) llvm::Function *cFun = llvm::Function::Create(commonfuncType, llvm::Function::PrivateLinkage, "c", module.get()); // Body of the `a` function { /// @brief Set entry label llvm::BasicBlock *block = llvm::BasicBlock::Create(context, "entry", aFun); /// @brief builder llvm::IRBui...
2018 Oct 17
1
invisible functions
> 2. change cfun[[1]] <- quote(cord.work) to cfun[[1]] <- > quote(survival:::cord.work). You say this will mess up your test bed. > That suggests that your test bed is broken. This is a perfectly legal > and valid solution. Valid in a package, but forces code to call a loaded library version of a f...
2007 Oct 12
3
collapsing a data frame
...e might want to specify more than one summary function, or specify that factors that vary within group should be dropped.) vtype = sapply(h,class) ## variable types [numeric or factor] vtypes = unique(vtype) ## possible types v2 = lapply(vtypes,function(z) which(vtype==z)) ## which are which? cfuns = list(factor=function(z)z[1],numeric=mean)## functions to apply m = mapply(function(w,f) { aggregate(h[w],list(h$BROOD),f) }, v2,cfuns,SIMPLIFY=FALSE) data.frame(m[[1]],m[[2]][-1]) My question is whether this is re-inventing the wheel. Is there some function or package that performs this ta...
2017 Jun 14
2
[WISH / PATCH] possibility to split string literals across multiple lines
...gantic loops the benefit is going to be significant. Take following example: atestfun <- function(x){ y <- paste0("a very long", "string for testing") grep(x, y) } atestfun2 <- function(x){ y <- "a very long string for testing" grep(x,y) } cfun <- cmpfun(atestfun) cfun2 <- cmpfun(atestfun2) require(rbenchmark) benchmark(atestfun("a"), atestfun2("a"), cfun("a"), cfun2("a"), replications = 100000) Which gives after 100,000 replications: test...
2019 Nov 04
2
Questions on the R C API
Hi All, I have some questions regarding the R C API. Let's assume I have a function which is defined as follows: R file: myfunc <- function(a, b, ...) .External(Cfun, a, b, ...) C file: SEXP Cfun(SEXP args) { args = CDR(args); SEXP a = CAR(args); args = CDR(args); SEXP b = CAR(args); args = CDR(args); /* continue to do something with remaining arguments in "..." using the same logic as above*/ return R_NilValue; } 1/ Let's suppose th...
2009 Feb 24
3
All the products of common factors
This is a seemingly simple problem - hopefully someone can help. Problem: we have two integers. We want (1) all the common factors, and (2) all the possible products of these factors. We know how to get (1), but can't figure out a general way to get (2). Example: 40 and 80 have these factors: c(1,2,2,2,5) and c(1,2,2,2,2,5). We can use match() to get the common factors c(1,2,2,2,5). What
2019 Nov 05
1
Questions on the R C API
...;morgan.emailbox at gmail.com> > wrote: > >> Hi All, >> >> I have some questions regarding the R C API. >> >> Let's assume I have a function which is defined as follows: >> >> R file: >> >> myfunc <- function(a, b, ...) .External(Cfun, a, b, ...) >> >> C file: >> >> SEXP Cfun(SEXP args) { >> args = CDR(args); >> SEXP a = CAR(args); args = CDR(args); >> SEXP b = CAR(args); args = CDR(args); >> /* continue to do something with remaining arguments in "..." using the...
2013 Apr 09
1
Solving an integral in R gives the error “The integral is probably divergent”
...l. The equation that I am trying to solve is as follows: $$ C_m = \frac{{abs{x}}e^{2x}}{\pi^{1/2}}\int_0^t t^{-3/2}e^{-x^2/t-t}dt $$ [image: enter image description here] The code that I am using is as follows: a <- seq(from=-10, by=0.5,length=100) ## Create a function to compute integrationCfun <- function(XX, upper){ integrand <- function(x)x^(-0.5)*exp((-XX^2/x)-x) integrated <- integrate(integrand, lower=0, upper=upper)$value (final <- abs(XX)*pi^(-0.5)*exp(2*XX)*integrated) } b<- sapply(a, Cfun, upper=1) The error that I am getting is as follows: Error in inte...
2017 Jun 14
0
[WISH / PATCH] possibility to split string literals across multiple lines
...ollowing example: > > atestfun <- function(x){ > y <- paste0("a very long", > "string for testing") > grep(x, y) > } > atestfun2 <- function(x){ > y <- "a very long > string for testing" > grep(x,y) > } > cfun <- cmpfun(atestfun) > cfun2 <- cmpfun(atestfun2) > > require(rbenchmark) > benchmark(atestfun("a"), > atestfun2("a"), > cfun("a"), > cfun2("a"), > replications = 100000) > > Which giv...
2019 Nov 04
0
Questions on the R C API
...Mon, Nov 4, 2019 at 2:41 PM Morgan Morgan <morgan.emailbox at gmail.com> wrote: > Hi All, > > I have some questions regarding the R C API. > > Let's assume I have a function which is defined as follows: > > R file: > > myfunc <- function(a, b, ...) .External(Cfun, a, b, ...) > > C file: > > SEXP Cfun(SEXP args) { > args = CDR(args); > SEXP a = CAR(args); args = CDR(args); > SEXP b = CAR(args); args = CDR(args); > /* continue to do something with remaining arguments in "..." using the > same logic as above*/ >...
2001 Oct 11
2
large dataframes to ascii
Hi R-users, I want to convert a large dataset (from stata format) to an ascii table. The resulting table should be a human-readable table (like CSV, or tab-separated file or something similar). R reads the stata-file quite easily (with some problems which are discussed here earlier), but so long I have not found a suitable way to write it in ascii format. Sure, there exists write.table, which
2012 May 11
0
[patch] Behavior of .C() and .Fortran() when given double(0) or integer(0) (repost).
...ent and DUP=FALSE: Pointer to arg: 0x275e0e0. Return value: [1] 0 Integer vector with 0 elements and DUP=FALSE: Pointer to arg: (nil). Return value: integer(0) -------------- next part -------------- sessionInfo() cat("\n") dyn.load("dotC_NULL.so") run_test<-function(desc,Cfun,args){ cat(desc,"\n") out <- do.call(".C",c(list(Cfun),args)) cat("Return value: ") print(out[[1]]) cat("\n") } run_test("R_alloc asked to allocate 1 byte:", "R_alloc_test",list(nbytes=as.integer(1))) run_test("R_alloc...
2017 Jun 14
4
[WISH / PATCH] possibility to split string literals across multiple lines
On Wed, 14 Jun 2017 06:12:09 -0500, Duncan Murdoch <murdoch.duncan at gmail.com> wrote: > On 14/06/2017 5:58 AM, Andreas Kersting wrote: > > Hi, > > > > I would really like to have a way to split long string literals across > > multiple lines in R. > > I don't understand why you require the string to be a literal. Why not > construct the long
2011 Sep 20
0
Using method = "aic" with pspline & survreg (survival library)
...egs of freedom - works fine fit1 <- survreg(Surv(time, status) ~ ph.ecog + pspline(age,3), cancer, dist="weibull") # weibull model with aic - gives an error fit1 <- survreg(Surv(time, status) ~ ph.ecog + pspline(age,method="aic"),dist="weibull", cancer) Error in (cfun[[1]])(parmlist[[1]], iter, iterlist[[1]], n.eff, pdf[1], : object 'loglik' not found I also get a similar error about "object 'loglik' not found" if I try to use method="aic" in the specification of a frailty term in a survreg model. Thanks for your help - a...
2009 Jul 02
3
[LLVMdev] LLVM under Syllable
I tried to Build LLVM under Syllable, but it was failed on the next moment http://clip2net.com/clip/m0/1246547164-clip-99kb.png any ideas? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090702/346df366/attachment.html>
1997 May 29
2
R-beta: WISH: For dyn.load()ing, I'd like is.loaded(.) , symbol.C, symbol.For
In S(plus), I can write functions using code fragments like if(!is.loaded(symbol.C("my_C_fun"))) dyn.load("......../my_C_fun.o") r <- .C("my_C_fun", x = x, n = n, ... ) which I would like to have in R, too. The S-plus help page on this subject says : S+>> Code Availability S+>> S+>> DESCRIPTION: S+>> is.loaded
2012 May 04
4
[patch] Behavior of .C() and .Fortran() when given double(0) or integer(0).
...ent and DUP=FALSE: Pointer to arg: 0x275e0e0. Return value: [1] 0 Integer vector with 0 elements and DUP=FALSE: Pointer to arg: (nil). Return value: integer(0) -------------- next part -------------- sessionInfo() cat("\n") dyn.load("dotC_NULL.so") run_test<-function(desc,Cfun,args){ cat(desc,"\n") out <- do.call(".C",c(list(Cfun),args)) cat("Return value: ") print(out[[1]]) cat("\n") } run_test("R_alloc asked to allocate 1 byte:", "R_alloc_test",list(nbytes=as.integer(1))) run_test("R_alloc...