Difference between revisions of "OpasnetUtils/Drafts"

From Opasnet
Jump to: navigation, search
(HNH2035 functions)
(Functions for ovariable diagnostics)
 
Line 22: Line 22:
  
 
=== Calculations ===
 
=== Calculations ===
 +
 +
====Expand_index====
 +
 +
<rcode name="expand_index" label="Initiate expand_index" embed=1>
 +
# This is code Op_en6007/expand_index in page [[OpasnetUtils/Drafts]]
 +
 +
library(OpasnetUtils)
 +
 +
#' Copies results from one location to other locations while keeping everything else constant
 +
#' @param ova ovariable to be used
 +
#' @param locations list of relevant indices. Each item is a list that has a name of an existing locations, and the content is a vector of new location names.
 +
#' @return the input ovariable with new rows containing the new locations
 +
 +
expand_index <- function(ova, locations) {
 +
  if("ovariable" %in% class(ova)) out <- ova@output else out <- ova
 +
  for(i in names(locations)) {
 +
    for(j in names(locations[[i]])) {
 +
      addpiece <- out[out[[i]]==j,]
 +
      for(k in locations[[i]][[j]]) {
 +
        addpiece[[i]] <- k
 +
        out <- rbind(out,addpiece)
 +
      }
 +
    }
 +
  }
 +
  if("ovariable" %in% class(ova)) ova@output <- out else ova <- out
 +
  return(ova)
 +
}
 +
 +
objects.store(expand_index)
 +
cat("Function expand_index stored.\n")
 +
</rcode>
  
 
====Functions for ovariable diagnostics====
 
====Functions for ovariable diagnostics====

Latest revision as of 10:37, 6 March 2021



Question

Which functions are so useful that they should be taken into OpasnetUtils package? This page contains draft function which will be included when they are good enough and found important.

Answer

Call the objects stored by this code from another rode with this command:

objects.latest("Op_en6007", code_name = "answer") # Old version that fetches all objects, depreciated and not updated.
objects.latest("Op_en6007", code_name = "diagnostics") # Functions for ovariable and model diagnostics: ovashapetest, showLoctable, binoptest
objects.latest("Op_en6007", code_name = "webropol") # Functions for operating with Webropol data
objects.latest("Op_en6007", code_name = "miscellaneous") # Functions for various tasks
objects.latest("Op_en6007", code_name = "gis") # Functions for ovariable, KML and Googl maps interactions

Rationale

Calculations

Expand_index

+ Show code

Functions for ovariable diagnostics

showind has problems with get() but this version of code was acceptable [1].

+ Show code

Functions for Webropol data

+ Show code

HNH2035 functions

These are functions that were needed and developed for the op_fi:Hiilineutraali Helsinki 2035 work.

+ Show code

Miscellaneous functions

+ Show code

Functions for GIS data

+ Show code

Timelineplot

+ Show code

See also

References


Related files

<mfanonymousfilelist></mfanonymousfilelist>