Branch creator: Difference between revisions

From Opasnet
Jump to navigation Jump to search
(user interface split into newpage, newdata, and newformula)
Line 10: Line 10:


=== Step 1: Create a page for branch ===
=== Step 1: Create a page for branch ===
{{bluebox|If the branch that you are working with already has a page, open the page for editing and go to step 2.}}


Open two copies of this page to your browser.  
Open two copies of this page to your browser.  
Line 24: Line 26:
=== Step 2: Fill in data about your branch ===
=== Step 2: Fill in data about your branch ===


Fill in the form below, click to create the content for the page, and copy-paste that onto the page you created in step 1. Save the page.
In step 2, you can create a new branch page or add more ovariables to an existing page. Fill in the form below, click to create content for the page, and copy-paste that onto the page you created in step 1. Save the page.
 
Each branch is a model that consists of sub-models called ovariables. If you don't know what they are, you should first read pages [[ovariable]] and [[modelling in Opanet]].


{{attack|# |Code works except that oprint puts and extra space between "< rcode" and that breaks the code created.|--[[User:Jouni|Jouni]] ([[User talk:Jouni|talk]]) 18:15, 5 March 2016 (UTC)}}
{{attack|# |Code works except that oprint puts and extra space between "< rcode" and that breaks the code created.|--[[User:Jouni|Jouni]] ([[User talk:Jouni|talk]]) 18:15, 5 March 2016 (UTC)}}


<rcode name="fill" label="Create content for the branch" recall_inputs=1 variables="
<rcode name="fill" label="Create content for the branch" recall_inputs=1 variables="
name:newpage|description:Do you want to create content for a new branch page?|type:selection|options:FALSE;No;TRUE;Yes|default:FALSE|
name:newdata|description:Do you want to create content for a new ovariable with data?|type:selection|options:FALSE;No;TRUE;Yes|default:FALSE|
name:newformula|description:Do you want to create content for a new ovariable with a formula?|type:selection|options:FALSE;No;TRUE;Yes|default:FALSE|
name:branchname|description:What was the branch name again?|type:text|
name:branchname|description:What was the branch name again?|type:text|
name:output.ovariable|description:Give a short name (no spaces!) to the final outcome variable in the branch model.|type:text|
category:Content for a new branch page|category_conditions:newpage;TRUE|
name:dependencies|description:What are the input variables for the outcome variable? Format c('var1', 'var2')|type:default|
name:output.ovariable0|description:Give a short name (no spaces!) for the ovariable that is the final outcome of the branch|type:text|
name:output.rationale|description:Give free-text rationale about what the outcome variable is and how it is calculated.|type:textbox|
name:intermediate.ovariable|description:Give a short name (no spaces!) for an ovariable with data|type:text|
name:intermediate.ovariable|description:Give a short name for one input variable (others are added afterwards if needed)|type:text|
category:Content for a new ovariable with data|category_conditions:newdata;TRUE|
name:t2bdata|description:Give a data table for the input variable|type:table|
name:t2bdata|description:Give a data table for the input variable|type:table|
name:intermediate.rationale|description:Give free-text rationale about what the intermediate variable is and how it is calculated.|type:textbox
name:intermediate.rationale|description:Give free-text rationale about what the intermediate variable is and how it is calculated.|type:textbox|
name:output.ovariable|description:Give a short name (no spaces!) to an ovariable with a formula.|type:text|
category:Content for a new ovariable with formula|category_conditions:newformula;TRUE|
name:dependencies|description:What are the input (parent or upstream) ovariables for this ovariable? Format c('var1', 'var2')|type:default|
name:formula|description:What is the formula that defines the calculations with the parents?|type:textbox|
name:output.rationale|description:Give free-text rationale about what the outcome variable is and how it is calculated.|type:textbox
">
">


Line 58: Line 70:
#</t2b>
#</t2b>


if(newpage) {


text1 <- paste("[[Category:Life cycle assessment]]
newpage <- paste("[[Category:Life cycle assessment]]
[[Category:Handprinter]]
[[Category:Handprinter]]
{{method|moderator=",
{{method|moderator=",
Line 83: Line 96:


objects.latest(paste('Op_en', PAGEID, sep = ''), code_name = '",
objects.latest(paste('Op_en', PAGEID, sep = ''), code_name = '",
output.ovariable,
output.ovariable0,
"')
"')


",
",
output.ovariable,
output.ovariable0,
" <- EvalOutput(",
" <- EvalOutput(",
output.ovariable,
output.ovariable0,
")
")


oprint(summary(",
oprint(summary(",
output.ovariable,
output.ovariable0,
"))
"))


Line 100: Line 113:
== Rationale ==
== Rationale ==


",
sep = "")
}


=== ",
if(newformula) {
 
newformula <- paste(
"=== ",
output.ovariable,
output.ovariable,
" ===
" ===
Line 131: Line 150:
   formula = function(...) {
   formula = function(...) {
     ",
     ",
output.ovariable,
formula,
" <- ",
" }
intermediate.ovariable,
"
    return(",
output.ovariable,
")
  }
)
)


Line 151: Line 164:


",
",
sep = "")
}
if(newdata) {
newdata <- paste(
"=== ",
"=== ",
intermediate.ovariable,
intermediate.ovariable,
Line 192: Line 210:
"
"
",
",
sep = "")
}
finale <- paste(
"== See also ==
"== See also ==


Line 200: Line 222:
",
",
sep = "")
sep = "")
text1 <- ""
if(!is.logical(newpage)) text1 <- paste(text1, newpage, collapse = "")
if(!is.logical(newdata)) text1 <- paste(text1, newdata, collapse = "")
if(!is.logical(newformula)) text1 <- paste(text1, newformula, collapse = "")
if(!is.logical(newpage)) text1 <- paste(text1, finale, collapse = "")


text2 <- strsplit(text1, split = "\n")[[1]]
text2 <- strsplit(text1, split = "\n")[[1]]
Line 205: Line 233:
text2 <- gsub("@", "<", text2)
text2 <- gsub("@", "<", text2)
text2 <- data.frame(Pagetemplate = text2)
text2 <- data.frame(Pagetemplate = text2)
text2
 
oprint(text2, include.rownames = FALSE)
oprint(text2, include.rownames = FALSE)
</rcode>
</rcode>

Revision as of 04:04, 7 March 2016



Question

How to create a branch for handprinter?

Answer

Step 1: Create a page for branch

If the branch that you are working with already has a page, open the page for editing and go to step 2.


Open two copies of this page to your browser. Give a name to your branch and click to create a new page for it. On the other page, continue from step 2.

<createbox> break=yes width=50 buttonlabel=Create branch align=left </createbox>

Step 2: Fill in data about your branch

In step 2, you can create a new branch page or add more ovariables to an existing page. Fill in the form below, click to create content for the page, and copy-paste that onto the page you created in step 1. Save the page.

Each branch is a model that consists of sub-models called ovariables. If you don't know what they are, you should first read pages ovariable and modelling in Opanet.

⇤--#: . Code works except that oprint puts and extra space between "< rcode" and that breaks the code created. --Jouni (talk) 18:15, 5 March 2016 (UTC) (type: truth; paradigms: science: attack)

Do you want to create content for a new branch page?:

Do you want to create content for a new ovariable with data?:

Do you want to create content for a new ovariable with a formula?:

Content for a new branch page

What was the branch name again?:

Give a short name (no spaces!) for the ovariable that is the final outcome of the branch:

Content for a new ovariable with data

Give a short name (no spaces!) for an ovariable with data:

Give a data table for the input variable:

Cancel

Give free-text rationale about what the intermediate variable is and how it is calculated.:

Content for a new ovariable with formula

Give a short name (no spaces!) to an ovariable with a formula.:

What are the input (parent or upstream) ovariables for this ovariable? Format c('var1', 'var2'):

What is the formula that defines the calculations with the parents?:

Give free-text rationale about what the outcome variable is and how it is calculated.:

+ Show code