Skip to content
Prev 367265 / 398506 Next

Make sure a data frame has been "fun through" a function

On Tue, 21 Feb 2017, stephen sefick wrote:

            
Sure. See comments (untested) inline.

Chuck
class(y) <- c("genotypes",class(y))
if(!(inherits("genotypes")){
 	stop("Need to pre-process data with functionA")}


or in functionA you could skip the class()<- and just set the
"impossible_genotypes" attribute to FALSE when there are none such.

Then here test

      if (is.null(attr(x,"impossible_genotypes"))){
 		stop("Need to pre-process data with functionA")
 	} else {
 		return(alleles)
 	}
impossible_genotype <- attr(x,"impossible_genotype")
maybe `!is.element(alleles,impossible_genotype)' is safer than `!='