OpasnetUtils/Drafts: Difference between revisions

From Opasnet
Jump to navigation Jump to search
(→‎Calculations: showind works now)
Line 23: Line 23:
=== Calculations ===
=== Calculations ===


'''Functions for ovariable diagnostics
====Functions for ovariable diagnostics====
 
showind has problems with get() but this version of code was acceptable [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=QcfKMkCd2ewUtZqP].
showind has problems with get() but this version of code was acceptable [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=QcfKMkCd2ewUtZqP].


Line 194: Line 195:
</rcode>
</rcode>


'''Functions for Webropol data
====Functions for Webropol data====


<rcode name="webropol" embed=1>
<rcode name="webropol" embed=1>
Line 266: Line 267:
</rcode>
</rcode>


'''Miscellaneous functions
====Miscellaneous functions====


<rcode name="miscellaneous" embed=1>
<rcode name="miscellaneous" embed=1>
Line 753: Line 754:
</rcode>
</rcode>


'''Functions for GIS data
====Functions for GIS data====


<rcode name="gis" embed=1>
<rcode name="gis" embed=1>
Line 1,037: Line 1,038:
objects.store(MyPointKML, ova2spat, MyRmap, MyPlotKML)
objects.store(MyPointKML, ova2spat, MyRmap, MyPlotKML)
cat("Functions MyPointKML, ova2spat, MyRmap, MyPlotKML stored.\n")
cat("Functions MyPointKML, ova2spat, MyRmap, MyPlotKML stored.\n")
</rcode>
==== Timelineplot ====
<rcode name="timelineplot" label="Initiate function timelineplot" embed=1>
# This is code Op_en6007/timelineplot on page [[OpasnetUtils/Drafts]]
library(OpasnetUtils)
#' @description plots timeline for an ovariable or data frame.
#' @param ova an ovariable
#' @param noshow character vector of Work items that are not shown on graph.
timelineplot <- function(ova, noshow=c("Ulos","Out")) {
  resn <- paste0(ova@name,"Result")
  if(class(ova)=="ovariable") out <- ova@output else out <- ova
  colnames(out)[colnames(out)==resn] <- "Time"
  # Make sure that data is ordered correcly.
  out <- out[order(out$Person, out$Time) , ]
 
  # Make endpoint for each task.
  b <- cbind(out[colnames(out)!="Work"], Work=c(NA,as.character(out$Work)[1:(nrow(out)-1)]))
  b$Work[match(unique(b$Person),b$Person)] <- NA
  out <- rbind(out,b)
  out <- na.omit(out[!out$Work %in% noshow , ])
  if(is.numeric(out$Time)) out$Time <- as.POSIXct(out$Time, origin="1970-01-01 00:00:00")
  pl <- ggplot(out, aes(x=Time,y=Person,colour=Work,group=paste0(Person,Work)))+geom_line(size=5)
  return(pl)
}
objects.store(timelineplot)
cat("Function timelineplot stored.\n")
</rcode>
</rcode>



Revision as of 16:44, 1 July 2018



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

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

Miscellaneous functions

+ Show code

Functions for GIS data

+ Show code

Timelineplot

+ Show code

See also

References


Related files

<mfanonymousfilelist></mfanonymousfilelist>