similar to: dispatch on functions (was: Re: ifelse(logical, function1, function2) does not work)

Displaying 20 results from an estimated 4000 matches similar to: "dispatch on functions (was: Re: ifelse(logical, function1, function2) does not work)"

2006 Oct 07
3
ifelse(logical, function1, function2) does not work
Why this kind of assignment does not work? n <- 1 f <- ifelse(n == 1, sin, cos) f(pi) this must be rewritten as: n <- 1 f <- cos if (n == 1) f <- sin f(pi) [oops. 1.224606e-16 instead of zero. Damn floating point errors :-/] Alberto Monteiro
2009 May 25
0
Or operator on working on the r-objects doesn't generate a logical value
Hi friends, Can somebody help me out please? I have to create a string for a particular if condition , with some values(returned by function1) which are always variable. *Step-I* Suppose function1 returns a dataframe like this,shown below with two values 3 and 4:--- x 1 3 2 4 *STEP-II *For creating the string with these values returned by function 1 i have another function2. These values
2012 Jul 30
6
Convert variable to STring
Dear all, I have a variable that I would like also to use it as a string. The reasons is that I want to collect results from different function to one table.. So when I use the  colnames(mymatrix) <-c(function1.function2,function3) the function1, function2, function3 to be "converted" to simple strings so as  colnames(mymatrix)
2012 Feb 09
3
calling the function which is stored in a list
Hi I'm storing two functions in a list # creating two function function1 <- function(n) { return(sum(n)) } function2 <- function(n) { return(mean(n)) } #storing the function function3 =c(function1,function2) is it possible to call the stored function and used it ? x=c(10,29) funtion3[1](x) Thanks ----- Thanks in Advance Arun -- View this message in context:
2008 Apr 22
2
optimization setup
Hi, here comes my problem, say I have the following functions (example case) #------------------------------------------------------------ function1 <- function (x, theta) {a <- theta[1] ( 1 - exp(-theta[2]) ) * theta[3] ) b <- x * theta[1] / theta[3]^2 return( list( a = a, b = b )) } #----------------------------------------------------------- function2<-function (x, theta) {P
2009 Dec 28
2
Ops method does not dispatch on either of two classes
I have defined boolean methods for bit and bitwhich objects, for example |.bit <- function(e1,e2) and |.bitwhich <- function(e1,e2) Both methods coerce their arguments to the respective class, however if I do something like bit_obj | bitwhich_obj then I get a warning Warning message: Incompatible methods ("|.bit", "|.bitwhich") for "|" and none of the
2013 Dec 20
0
How to force dispatch to an internal generic?
Dear R-devel, I have a class 'myClass' in R that is essentially a list with pre-specified structure. It has an assignment operator which is going to do some things and then should assign the value using the regular list assignment operator `$<-.myClass`<-function(x,i,value){ # do some pre-processing stuff # make the assignment using the default list assignment
2009 Dec 22
1
[LLVMdev] is there a compiler barrier that is effective at codegen level?
Hi, I would like to prevent that two adjacent calls to external functions getting interleaved/separated by other neighboring code. This mixing seems to happen in the code generator. I can prevent it by putting the two calls into a separate BB, but then I can't use -simplifycfg, -jump-threading, ... as is. Here is an example: %160 = add i64 %158, %159 ; <i64>
2010 Feb 25
1
error in lmLists in lme4 package (bug?)
Hello, I am trying to use lmLists in the lme4 package and copying over very standard code from the nlme package given in 'Mixed-Effects Models in S and S-Plus'. It appears to not accept an 'I(age-11)' in the formula, though it will accept the formula with out the subtraction of 11 from age. This seems like it would be a bug, since this is standard formula syntax, unless
2014 Jun 11
3
[LLVMdev] How do clang & clang++ choose function names for LLVM IR?
Hello all, I'm getting started on a project using LLVM's opt tool to do static analysis, printing call graphs and such. When compiling C programs to IR (and eventually to call graphs), function names remain the same (main, function1, function2 etc.), but when compiling the same program as C++, the function names often have cruft added to them (_Z9function1v, _Z9function2v etc.) which
2008 Jun 05
1
is() and S3 classes
The is() function begins with the following code: cl <- class(object) if (length(cl) > 1) { if (is.na(match(cl[[1]], names(getClass("oldClass")@subclasses)))) return(class2 %in% cl) As one can see, it uses S3 inheritance if the first element of the class attribute is an "oldClass". In R prior to 2.7, is() would check S4 inheritance if any
2005 Aug 06
1
oldClass vs. class
Hi,When I read the source of str,i find these code ----- ## Show further classes // Assume that they do NOT have an own Method -- ## not quite perfect ! (.Class = 'remaining classes', starting with current) cl <- oldClass(object); cl <- cl[cl != "data.frame"] #- not THIS class ----- so I use ?oldClass to try to learn more about oldClass.But after I have reading
2006 Dec 12
1
strings as factors
Hi, To be able to match cases with a benchmark I need to have a data.frame with a character id variable. however, I am surprised why this seems to be so hard. In fact I was unable to succeed. Here is what I tried: >test1 <-expand.grid(ID = 1:2, sex = c("male","female")) >is(test1[,2]) [1] "factor" "oldClass" >test2 <-expand.grid(ID =
2017 Nov 29
2
binary form of is() contradicts its unary form
Hi, The unary forms of is() and extends() report that data.frame extends list, oldClass, and vector: > is(data.frame()) [1] "data.frame" "list" "oldClass" "vector" > extends("data.frame") [1] "data.frame" "list" "oldClass" "vector" However, the binary form of is()
2009 Dec 03
2
Error in namespaceExport(ns, exports) :
Dear all, I get the error "Error in namespaceExport(ns, exports) : undefined exports function1 , function2" when compiling or even when I roxygen my package. The two function I once had in my package but I deleted them including their .Rd files. I also can't find them in any other function or help file. So does anybody know where these functions are still listed that causes
2009 Dec 03
2
Error in namespaceExport(ns, exports) :
Dear all, I get the error "Error in namespaceExport(ns, exports) : undefined exports function1 , function2" when compiling or even when I roxygen my package. The two function I once had in my package but I deleted them including their .Rd files. I also can't find them in any other function or help file. So does anybody know where these functions are still listed that causes
2008 Feb 20
1
Problem Using the %in% command
Hello all! I have the following problem with the %in% command: 1) I have a data frame that consists of functions (rows) and genes (columns). The whole has been loaded with the "read.delim" command because of gene-duplications between the different rows. 2) Now, there is another data frame that contains all the genes (only the genes and without duplicates) from all the functions of
2017 Nov 29
0
binary form of is() contradicts its unary form
Hi Herve, I think you are confusing subclasses and classes. There is no contradiction. `is` documentation is very clear: `With one argument, returns all the super-classes of this object's class.` Note that object class is always `data.frame` here, check: > class(data.frame()) [1] "data.frame" > is(data.frame(), "data.frame") [1] TRUE Best, Mehmet On 29 Nov
2013 Feb 27
0
How to specify ff object filepaths when reading a CSV file into a ff data frame.
Really old subject?, so, all my apologizes for digging up but, since I also ran into this? maybe this hack can be useful to someone I propose monkey patching here: library(ff) my.as.ffdf.data.frame <- function (x, vmode = NULL, col_args = list(), ...) { rnam <- attr(x, "row.names") if (is.integer(rnam)) { if (all(rnam == seq_along(rnam))) rnam <- NULL else
2007 Jul 31
1
Getting variable name used in function...
Dear Users, I am using functions for calculations in my study. I have two functions and one is calling the other two times one after another. But the called function deals with two different data object (matrix, data frame, etc.), so I could not make the second function output data object-free (for example, Ý would like to write csv files but could not give different file names) and I would