Difference between revisions of "OpasnetUtils/Ops"
From Testiwiki
m |
(→Code: comments added) |
||
Line 10: | Line 10: | ||
==Code== | ==Code== | ||
+ | |||
+ | {{attack|# |You cannot use code "callGeneric(e2, e1)" with other order than original, because some functions like "/" and "-" cannot be reordered.|--[[User:Jouni|Jouni]] 23:30, 1 July 2012 (EEST)}} | ||
+ | |||
<rcode | <rcode | ||
name="answer" | name="answer" |
Revision as of 20:30, 1 July 2012
This page is a method.
The page identifier is Op_en5736 |
---|
Moderator:Nobody (see all) Click here to sign up. |
This page is a stub. You may improve it into a full page, and then a rating bar will appear here. |
Upload data
|
Description
Arithmetic operations of ovariables: first they are merged by index columns, then the operation is performed for the Result.x and Result.y columns.
If one of the expressions is numeric, it is first transformed to ovariable.
Code
⇤# : You cannot use code "callGeneric(e2, e1)" with other order than original, because some functions like "/" and "-" cannot be reordered. --Jouni 23:30, 1 July 2012 (EEST)
# SETMETHOD OPS ######### Arithmetic operations of ovariables: first they are merged by index columns, ### then the operation is performed for the Result.x and Result.y columns. ### If one of the expressions is numeric, it is first transformed to ovariable. temp <- setMethod( f = "Ops", signature = signature(e1 = "ovariable", e2 = "ovariable"), definition = function(e1, e2) { out <- merge(e1, e2)@output colnames(out) <- gsub(".x", "", colnames(out)) out$Result <- callGeneric(out$Result, out$Result.y) if(!is.null(out$Unit.y)) {out$Unit <- paste(out$Unit, "|(", out$Unit.y, ")", sep= "")} e1@output <- out[, !colnames(out) %in% c("Result.y", "Unit.y")] return(e1) } ) temp <- setMethod( f = "Ops", signature = signature(e1 = "ovariable", e2 = "numeric"), definition = function(e1, e2) { e2 <- make.ovariable(e2) e1 <- callGeneric(e1, e2) return(e1) } ) temp <- setMethod( f = "Ops", signature = signature(e1 = "numeric", e2 = "ovariable"), definition = function(e1, e2) { e1 <- make.ovariable(e1) e1 <- callGeneric(e2, e1) return(e1) } ) |