OpasnetUtils/Summary: Difference between revisions
Jump to navigation
Jump to search
(→Code: Vain yksi iteraatio) |
(→Description: idea about summary.ovariable) |
||
| Line 6: | Line 6: | ||
==Description== | ==Description== | ||
Summary defines how summaries of [[OpasnetUtils/Ovariable|ovariables]] are shown. | Summary defines how summaries of [[OpasnetUtils/Ovariable|ovariables]] are shown. | ||
What the summary function should do for ovariables? | |||
* Use parameters | |||
** x (ovariable), | |||
** rescol (optional, default is paste(x@name, "Result", sep = "")), | |||
** oper (a character vector of function names), | |||
** marginal (a vector of column names, or a logical vector with the same length as ncol(data). | |||
* Define data by doing EvalOutput(x)@output. | |||
* Define result column to be used in tapply based on rescol. | |||
* Define conditional columns based on marginal. If marginal is not given, use all columns except a) the result columns and b) all columns that end "Description", "Unit", or "Source". Note that if you have "jointed" some columns from marginals to joint and then you still use them as marginals, the function works but the result will be wrong. | |||
* Within oper, character strings can be used as functions in tapply if they correspond to a function that does not need other parameters than data$rescol. However, if the user wants to do e.g. quantile(data$rescol, 0.025), then this is given in oper as "Q0.025", and that string is converted to a temporary function in this way: assign(paste("temporary.function", i, sep = ""), function(x) {quantile(x, as.numeric(gsub("Q", "", oper[i])))}). Functions other than quantile with parameters may be defined in a similar way. | |||
* Do as.data.frame(as.table(tapply(rescol, marginal, oper[[i]]))) for each item i in list oper. You will get a list of data.frames. | |||
* Remove empty rows from all data.frames with out[!is.na(out$Freq), ]. | |||
* Merge these data.frames using marginal columns as conditions, and using all = TRUE so that empty cells will appear if one of the functions is not able to produce a result for a row but another is. | |||
* Create an ovariable with the name paste(x@name, "Summary", sep = ""), dependencies = x, function = summary(), output = data.frame just created. {{attack|# |Or is it just easier to use the data.frame as the output?|--[[User:Jouni|Jouni]] 11:38, 26 February 2013 (EET)}} | |||
* Return the ovariable. | |||
==Code== | ==Code== | ||
Revision as of 09:38, 26 February 2013
| Moderator:Nobody (see all) Click here to sign up. |
| This page is a stub. You may improve it into a full page. |
| Upload data
|
Description
Summary defines how summaries of ovariables are shown.
What the summary function should do for ovariables?
- Use parameters
- x (ovariable),
- rescol (optional, default is paste(x@name, "Result", sep = "")),
- oper (a character vector of function names),
- marginal (a vector of column names, or a logical vector with the same length as ncol(data).
- Define data by doing EvalOutput(x)@output.
- Define result column to be used in tapply based on rescol.
- Define conditional columns based on marginal. If marginal is not given, use all columns except a) the result columns and b) all columns that end "Description", "Unit", or "Source". Note that if you have "jointed" some columns from marginals to joint and then you still use them as marginals, the function works but the result will be wrong.
- Within oper, character strings can be used as functions in tapply if they correspond to a function that does not need other parameters than data$rescol. However, if the user wants to do e.g. quantile(data$rescol, 0.025), then this is given in oper as "Q0.025", and that string is converted to a temporary function in this way: assign(paste("temporary.function", i, sep = ""), function(x) {quantile(x, as.numeric(gsub("Q", "", oper[i])))}). Functions other than quantile with parameters may be defined in a similar way.
- Do as.data.frame(as.table(tapply(rescol, marginal, operi))) for each item i in list oper. You will get a list of data.frames.
- Remove empty rows from all data.frames with out[!is.na(out$Freq), ].
- Merge these data.frames using marginal columns as conditions, and using all = TRUE so that empty cells will appear if one of the functions is not able to produce a result for a row but another is.
- Create an ovariable with the name paste(x@name, "Summary", sep = ""), dependencies = x, function = summary(), output = data.frame just created. ⇤--#: . Or is it just easier to use the data.frame as the output? --Jouni 11:38, 26 February 2013 (EET) (type: truth; paradigms: science: attack)
- Return the ovariable.
Code
Code name: summary