Skip to content
Snippets Groups Projects
Commit 82176ebb authored by pbac's avatar pbac
Browse files

Merge branch 'develop'

parents 656fece3 e9bd8718
No related branches found
No related tags found
No related merge requests found
......@@ -23,3 +23,5 @@ vignettes/*genfig*
vignettes/*_files*
tmp/
onlineforecast.Rcheck
\ No newline at end of file
Package: onlineforecast
Type: Package
Title: Forecast Modelling for Online Applications
Version: 0.9.1
Description: A framework for fitting adaptive forecasting models. Provides a way to use forecasts as input to models, e.g. weather forecasts for energy related forecasting. The models can be fitted recursively and can easily be setup for updating parameters when new data arrives. See the included vignettes, the website <https://onlineforecasting.org> and Bacher et. al. (2013, <doi:10.1016/j.enbuild.2013.04.022>).
Version: 0.9.3
Description: A framework for fitting adaptive forecasting models. Provides a way to use forecasts as input to models, e.g. weather forecasts for energy related forecasting. The models can be fitted recursively and can easily be setup for updating parameters when new data arrives. See the included vignettes, the website <https://onlineforecasting.org> and the paper "Short-term heat load forecasting for single family houses" <doi:10.1016/j.enbuild.2013.04.022>.
License: GPL-3
Encoding: UTF-8
LazyData: true
......@@ -22,8 +22,9 @@ Suggests:
rmarkdown,
R.rsp,
testthat (>= 2.1.0),
data.table
data.table,
plotly
VignetteBuilder: knitr
RoxygenNote: 7.1.1
URL: http://onlineforecasting.org
URL: https://onlineforecasting.org
BugReports: https://lab.compute.dtu.dk/packages/onlineforecast/-/issues
......@@ -23,7 +23,7 @@
#' # A function for demonstrating the using caching
#' fun <- function(x, y){
#' # Generate the cache name (no argument given, so both x and y is used)
#' nm <- cache_name()
#' nm <- cache_name(cachedir=cachedir)
#' # If the result is cached, then just return it
#' if(file.exists(nm)){ return(readRDS(nm)) }
#' # Do the calculation
......@@ -35,6 +35,10 @@
#' # Return
#' return(res)
#' }
#'
#' # For this example use a temporary directory
#' # In real use this should not be temporary! (changes between R sessions with tempdir())
#' cachedir <- tempdir()
#'
#' # First time it takes at least 1 sec.
#' fun(x=2,y=2)
......@@ -43,9 +47,9 @@
#' # Try changing the arguments (x,y) and run again
#'
#' # See the cache file(s)
#' dir("cache")
#' # Delete the cache
#' file.remove(dir("cache", full.names=TRUE))
#' dir(cachedir)
#' # Delete the cache folder
#' unlink(cachedir, recursive=TRUE)
#'
#' # Demonstrate how cache_name() is functioning
#' # Cache using the all objects given in the function calling, i.e. both x and y
......@@ -59,10 +63,6 @@
#' fun(y=2,x=1)
#' # But this one is different
#' fun(x=2,y=1)
#' \dontshow{
#' # Testing
#' if(fun(1,2) != fun(x=1,y=2) | fun(1,2) != fun(y=2,x=1)){ stop("A problem with cache_name() exists.") }
#' }
#'
#' # Test: cache using the values specified in the cache_name call
#' fun2 <- function(x,y){
......@@ -77,7 +77,6 @@
#' fun2(3,3)
#' # And the function named changed the name
#'
#'
#' @export
cache_name <- function(..., cachedir = "cache"){
# Get the name, definition and arguments of the function from which cache_name was called
......
......@@ -67,7 +67,7 @@ data.list <- function(...) {
#' subset(D, c("2010-12-15 02:00","2010-12-15 04:00"))
#'
#' # Cannot request a variable not there
#' \donttest{try(subset(D, nms=c("x","Ta")))}
#' try(subset(D, nms=c("x","Ta")))
#'
#' # Take specific horizons
#' subset(D, nms=c("I","Ta"), kseq = 1:2)
......
......@@ -169,11 +169,11 @@
#'
#' # Check if the model is setup and can be used with a given data.list
#' # An error is thrown
#' \donttest{try(model$check(Dbuilding))}
#' try(model$check(Dbuilding))
#' # Add the model output
#' model$output <- "heatload"
#' # Still not error free
#' \donttest{try(model$check(Dbuilding))}
#' try(model$check(Dbuilding))
#' # Add the horizons to fit for
#' model$kseq <- 1:4
#' # Finally, no errors :)
......
......@@ -30,8 +30,7 @@
#' lagdf(1:10, c(1:3))
#' lagdf(1:10, c(5,3,-1))
#'
#' # See also how to lag a forecast data.frame
#' ?lagdf.data.frame
#' # See also how to lag a forecast data.frame with: ?lagdf.data.frame
#'
#'
#'@export
......@@ -99,9 +98,9 @@ lagdf.logical <- function(x, lagseq) {
#' names(X) <- gsub("k", "h", names(X))
#' lagdf(X, "-h")
#'
#' # If not same length as columns in X, then it doesn't know how to lag, so an error is thrown
#' \donttest{try(lagdf(X, 1:2))}
#'
#' # If lagseq must have length as columns in X, it doesn't know how to lag and an error is thrown
#' try(lagdf(X, 1:2))
#'
#' \dontshow{
#' if(!class(lagdf(data.frame(k1=1:10), 2)) == "data.frame"){stop("Trying to lag data.frame with 1 column, but return is not class data.frame")}
#' if(!all(dim(lagdf(data.frame(k1=1:10), "+k")) == c(10,1))){stop("Trying to lag data.frame with 1 column, but return is not class data.frame")}
......
......@@ -13,7 +13,7 @@
#'
#' Note that the plot parameters set with \code{\link{par_ts}()} have no effect on the \code{plotly} plots.
#'
#' See \url{http://https://onlineforecasting.org/vignettes/nice-tricks.html}.
#' See \url{https://onlineforecasting.org/vignettes/nice-tricks.html}.
#'
#' @rdname plot_ts
#' @examples
......
......@@ -8,7 +8,8 @@
#'
#' A simple function, which sets the \code{\link{par}()} plotting parameters to a default set of values.
#'
#' Actually, only really used for setting useful \code{par} values for multiple time series plots with same x-axis. Give \code{tmpl="ts"} and \code{mfrow=c(x,1)}, where x is the number of plots.
#' Actually, only really used for setting useful \code{par} values for multiple time series plots with same x-axis.
#' Give \code{tmpl="ts"} and \code{mfrow=c(x,1)}, where x is the number of plots.
#'
#' @title Setting \code{\link{par}()} plotting parameters
#' @param tmpl The name of the parameter template, give "ts" as default
......@@ -19,6 +20,8 @@
#'
#' # Make some data
#' D <- data.frame(t=seq(ct("2020-01-01"),ct("2020-01-10"),len=100), x=rnorm(100), y=runif(100))
#' # Remember the currect par values
#' oldpar <- setpar()
#'
#' # Generate two stacked plots with same x-axis
#' setpar("ts", mfrow=c(2,1))
......@@ -26,8 +29,12 @@
#' plot(D$t, D$y, type="l")
#' # Note xaxt="s" must be set
#' axis.POSIXct(1, D$t, xaxt="s", format="%Y-%m-%d")
#'
#' # Set back the par to the previous
#' par(oldpar)
#'
#' # In a function, where this is used and a plot is generated, do like this to reset on exit
#' # In a function, where this is used and a plot is generated,
#' # then do like this in order to automatically reset on exit
#' oldpar <- setpar(mfrow=c(2,1))
#' on.exit(par(oldpar))
#'
......
#----------------------------------------------------------------
# v0.9.1
# v0.9.3
# Response to review of v0.9.2 by Uwe Ligges
#--------
REQUEST:
> 1) Yes, a few times I want to show an error in the examples, should the e.g. "try(getse(x, 1))" be inside \donttest{ } ?
Not needed, you can simply run try() in zthe examples.
RESPONSE:
Fixed.
#--------
#--------
REQUEST:
> 2) I do see the point about setting back par() and options(). It's actually one function which sets par (options are not set in any functions):
>
> - setpar() is just a wrapper for changing the par values to certain values, it's only used in plot_ts(), where the par is reset on exit. So in setpar() it can't really reset the par, since then it would make sense to have it. setpar() returns the current parameters, so they can be reset after plotting. So I think it makes sense to have it, if allowed!?
If you do
op <- setpar()
on.exit(setpar(op))
it should be fine.
RESPONSE:
Fixed.
#--------
#--------
REQUEST:
> 3) I see also the point about not writing files, however the demonstration of caching e.g. "val <- lm_optim(model, D, cachedir=tempdir())" really needs a constant path, it can't be tempdir(), since it changes the returned value between R sessions.
Yes, between R sessions, but within the session a user can inpsect the
files. Users may well change the path(). See the CRAN policies.
> So it's only meaningful to use a constant path, like "cache" and let the user see where the cache files ends up (such that they can also understand how to remove them etc.). It's inspired by the knitr package, which does exactly the same. I can't right now figure out how to fix that in a nice way...I could comment it out and let the user uncomment, args, not a good idea ;D...well, I could remove it in the help and in the included vignettes, and put a link to the website and describe it there, do you have a better solution?
Simply always use the tempdir() in example, that way <you won't pollute
the user filespace nor overwrite fiels in user filespace.
RESPONSE:
Fixed. Only one example now write a file (in function R/cache_name.R), and it uses tempdir().
#--------
#----------------------------------------------------------------
#----------------------------------------------------------------
# v0.9.1 and v0.9.2
Response to review of v0.9.0 by Swetlana Herbrandt:
#--------
......
......@@ -10,7 +10,7 @@ citEntry(
number = "0",
pages = "101-112",
doi = "10.1016/j.enbuild.2013.04.022",
url = "http://onlineforecasting.org",
url = "https://onlineforecasting.org",
textVersion = paste(
"We are in process of writing a journal paper about the package, but for now we referer to the paper 'Short-term heat load forecasting for single family houses', in which the implemented modelling is described."
)
......
......@@ -63,7 +63,7 @@ document()
build(".", vignettes=TRUE)
# Install it
install.packages("../onlineforecast_0.9.1.tar.gz")
install.packages("../onlineforecast_0.9.3.tar.gz")
library(onlineforecast)
# ----------------------------------------------------------------
......@@ -71,7 +71,7 @@ library(onlineforecast)
# ----------------------------------------------------------------
# Build binary package
#system("R CMD INSTALL --build ../onlineforecast_0.9.1.tar.gz")
#system("R CMD INSTALL --build ../onlineforecast_0.9.3.tar.gz")
# ----------------------------------------------------------------
......@@ -80,10 +80,11 @@ library(onlineforecast)
# Test before release
devtools::check()
devtools::check_built("../onlineforecast_0.9.1.tar.gz")
devtools::check_built("../onlineforecast_0.9.3.tar.gz")
# Does give different results than check() above
system("R CMD check ../onlineforecast_0.9.1.tar.gz")
#system("R CMD check --as-cran ../onlineforecast_0.9.3.tar.gz")
system("R CMD check ../onlineforecast_0.9.3.tar.gz")
unlink("onlineforecast.Rcheck/", recursive=TRUE)
# Use for more checking:
......
......@@ -451,7 +451,7 @@ model$add_inputs(Tao = "lp(Tao, a1=0.99)")
Working with time consuming calculations caching can be very
valuable. The optimization results can be cached by providing a path to a
directory, by setting the argument 'cachedir' to e.g. "cache". See the vignette
[nice-tricks](https://onlineforecast.org/vignettes/nice-tricks.html) for an
[nice-tricks](https://onlineforecasting.org/vignettes/nice-tricks.html) for an
example with code.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment