Error Is.atomicx Is Not True
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more is.atomic r about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges
What Is A Recursive Object
Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each what is an atomic object other. Join them; it only takes a minute: Sign up Using sd as a generic function in R up vote 8 down vote favorite If I a have a class called foo, then it is straightforward to overload the operator is invalid for atomic vectors r summary function summary.foo = function(x, ...) print("bar") However this technique does not work with the sd function, that is > bar = createFooClass() > sd.foo = function(x, ...) print("Hi") > sd(bar) error: is.atomic(x) is not TRUE What is the correct way of overloading this function? oop r r-s3 share|improve this question edited Nov 15 '11 at 14:45 asked Jan 18 '11 at 19:48 csgillespie 31.8k969117 add a comment| 3 Answers 3 active oldest votes up vote 7
Atomic Radius
down vote accepted You can hijack any non-generic function, make it (S3) generic and set the original version to be the default version. For example: ## make an S3 generic for sd sd <- function(x, ...) UseMethod("sd") ## take the usual definition of sd, ## and set it to be the default method sd.default <- stats::sd ## create a method for our class "foo" sd.foo = function(x, ...) print("Hi") A final step, if this is in a package, is to add a ... argument to sd.default to allow passing of package checks: formals(sd.default) <- c(formals(sd.default), alist(... = )) giving: > args(sd.default) function (x, na.rm = FALSE, ...) NULL > args(stats::sd) function (x, na.rm = FALSE) NULL This then gives the desired behaviour: > bar <- 1:10 > sd(bar) [1] 3.027650 > class(bar) <- "foo" > sd(bar) [1] "Hi" This is documented in section 7.1 of the Writing R Extensions manual share|improve this answer edited Jan 18 '11 at 23:39 answered Jan 18 '11 at 23:26 Gavin Simpson 104k13209304 Better to email R-devel and request that sd (or better, var) be made generic. –hadley Nov 15 '11 at 16:06 @hadley agreed, but as well as the need for R Core to maintain this, there is a performance hit when making something generic, hence the wording and advice in the R Ext. Manual. –Gavin Simpson Nov 15 '11 at
otherwise. Usage is.atomic(x) is.recursive(x) Arguments x object to be tested. Details is.atomic is true for the atomic vector http://stackoverflow.com/questions/4728342/using-sd-as-a-generic-function-in-r types ("logical", "integer", "numeric", "complex", "character" and "raw") and NULL. Most types of language objects are regarded as recursive: those which are not are the atomic vector http://astrostatistics.psu.edu/su07/R/html/base/html/is.recursive.html types, NULL and symbols (as given by as.name). References Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole. See Also is.list, is.language, etc, and the demo("is.things"). Examples is.a.r <- function(x) c(is.atomic(x), is.recursive(x)) is.a.r(c(a=1,b=3)) # TRUE FALSE is.a.r(list()) # FALSE TRUE ?? is.a.r(list(2)) # FALSE TRUE is.a.r(lm) # FALSE TRUE is.a.r(y ~ x) # FALSE TRUE is.a.r(expression(x+1)) # FALSE TRUE (not in 0.62.3!) [Package base version 2.5.0 Index]
years ago by Anthony Bosco • 10 Anthony Bosco • 10 wrote: Dear list, I am having trouble using the function betr (BioC package betr).. I am providing the required arguments (cond, timepoint, replicate) in the correct https://support.bioconductor.org/p/31769/ length and class, as well as a data matrix (exprs). However I get the following https://support.bioconductor.org/p/31783/ error Error: is.atomic(x) is not TRUE This occurs even though is.atomic(exprs) = TRUE I also get the following warnings... > warnings() Warning messages: 1: In mean.default(newX[, i], ...) : argument is not numeric or logical: returning NA 2: In mean.default(newX[, i], ...) : argument is not numeric or logical: returning NA 3: In mean.default(newX[, i], ...) : argument is not numeric or what is logical: returning NA 4: In mean.default(newX[, i], ...) : argument is not numeric or logical: returning NA 5: In mean.default(newX[, i], ...) : argument is not numeric or logical: returning NA 6: In mean.default(newX[, i], ...) : argument is not numeric or logical: returning NA 7: In mean.default(newX[, i], ...) : argument is not numeric or logical: returning NA 8: In mean.default(newX[, i], ...) : argument is not numeric or logical: returning NA 9: In mean.default(newX[, i], what is a ...) : argument is not numeric or logical: returning NA 10: In mean.default(newX[, i], ...) : argument is not numeric or logical: returning NA 11: In mean.default(newX[, i], ...) : betr ADD COMMENT • link • Not following Follow via messages Follow via email Do not follow written 6.7 years ago by Anthony Bosco • 10 Please log in to add an answer. Similar posts • Search » is.atomic error with betr function > Date: Thu, 11 Feb 2010 17:33:15 -0700 > From: "Anthony Bosco" > To: bioconductor at s... Mfuzz: fill.NA - Warning messages: argument is not numeric or logical: returning NA Hello, I try to fill my missing identified value (NA) with mean between 7 time course experiment.... help w/ bg.correct.gcrma The first try should read like this: bgaffy <-bg.correct.gcrma(rawaffy,gcgroup=getGroupInfo(r... limma Composite Normalisation & Plotting Hi All (using R 1.8.0, limma 1.5.1) I'm slightly confused with the composite normalisation wh... Unable to \'standardise\' logtransformed dataset of contrasts using Mfuzz package Dear Maintainer, I'm analyzing metabolomic LC-MS intensity values. To reduced these large numbe... Enabling the widget option Hello, I am a new user of BioConductor and would like to seek some guidance. I am trying to use ... help w/ bg.correct.gcrma Hi, I want to explore the GC-based background correction in gcrma. I'd like to get the bg correc... Ignore maanova warning messages? Reposting with new sub
years ago by Martin Aryee • 20 Martin Aryee • 20 wrote: > Date: Thu, 11 Feb 2010 17:33:15 -0700 > From: "Anthony Bosco"