diff --git a/DESCRIPTION b/DESCRIPTION index ecbd4d0bd3dc7a91a827f8b6776b6aeaf0c93a27..adba77e773003159f66422996bc803160133085b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,7 +23,7 @@ Suggests: testthat (>= 2.1.0), data.table, plotly -VignetteBuilder:knitr -RoxygenNote: 7.1.0 +VignetteBuilder: knitr +RoxygenNote: 7.1.1 URL: http://onlineforecasting.org BugReports: https://lab.compute.dtu.dk/packages/onlineforecast/-/issues diff --git a/R/data.list.R b/R/data.list.R index 794e9e14e500f80c1010d612eea98f86f182d386..1822f9c7d7b1699032de180a59dd1b7616ce018b 100644 --- a/R/data.list.R +++ b/R/data.list.R @@ -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{subset(D, nms=c("x","Ta"))} +#' \donttest{#subset(D, nms=c("x","Ta"))} #' #' # Take specific horizons #' subset(D, nms=c("I","Ta"), kseq = 1:2) @@ -410,7 +410,6 @@ check.data.list <- function(object){ #' #' @examples #' -#' \donttest{ #' Dbuilding == Dbuilding #' #' D <- Dbuilding @@ -421,8 +420,9 @@ check.data.list <- function(object){ #' names(D)[5] <- "I" #' names(D)[6] <- "Ta" #' Dbuilding == D -#' } #' +#' +#' @export "==.data.list" <- function(x, y) { if(length(x) != length(y)){ diff --git a/R/forecastmodel.R b/R/forecastmodel.R index 562058afecb48c6868e0ed86315bbc61cb5ae75a..b2e85f885ca8807a87a6d1756787d6451ca17ec6 100644 --- a/R/forecastmodel.R +++ b/R/forecastmodel.R @@ -183,10 +183,10 @@ forecastmodel <- R6::R6Class("forecastmodel", public = list( # Evaluate the expression (input$expr) L <- input$evaluate(data) # Must return a list - if(class(L)=="matrix"){ return(list(as.data.frame(L))) } - if(class(L)=="data.frame"){ return(list(L)) } - if(class(L)!="list"){ stop(pst("The value returned from evaluating: ",input$expr,", was not a matrix, data.frame or a list of them."))} - if(class(L[[1]])=="matrix"){ return(lapply(L, function(mat){ return(as.data.frame(mat)) })) } + if(class(L)[1]=="matrix"){ return(list(as.data.frame(L))) } + if(class(L)[1]=="data.frame"){ return(list(L)) } + if(class(L)[1]!="list"){ stop(pst("The value returned from evaluating: ",input$expr,", was not a matrix, data.frame or a list of them."))} + if(class(L[[1]])[1]=="matrix"){ return(lapply(L, function(mat){ return(as.data.frame(mat)) })) } return(L) }) # Put together in one data.list diff --git a/R/forecastmodel.R-documentation.R b/R/forecastmodel.R-documentation.R index cca211075ca17ba0495b8bbbff854b43f002a4f5..8640b63ea1434457f41bb31763c3f60d4307e904 100644 --- a/R/forecastmodel.R-documentation.R +++ b/R/forecastmodel.R-documentation.R @@ -168,10 +168,10 @@ #' @examples #' #' # Check if the model is setup and can be used with a given data.list -#' \donttest{model$check(Dbuilding)} +#' \donttest{#model$check(Dbuilding)} #' # Add the model output #' model$output <- "heatload" -#' \donttest{model$check(Dbuilding)} +#' \donttest{#model$check(Dbuilding)} #' # Add the horizons to fit for #' model$kseq <- 1:4 #' # No errors, it's fine :) diff --git a/R/getse.R b/R/getse.R index 2f906055b19239021d2380786bb40c531cdc42bc..8ea6a600bf44306f0f96f9490524a464214896d3 100644 --- a/R/getse.R +++ b/R/getse.R @@ -51,14 +51,13 @@ #' getse(x, 2) #' #' # Will give an error when indexed (with integer) if the element is not there -#' \donttest{ -#' x <- strsplit(c("x.k1","y.k2","x2"), "\\.") -#' getse(x, 1) -#' getse(x, 2) -#' +#' \donttest{x <- strsplit(c("x.k1","y.k2","x2"), "\\.") +#' #getse(x, 1) +#' #getse(x, 2) +#' } #' # Use regex pattern for returning elements matching in the specified layer #' getse(L, "^te", depth=2, useregex=TRUE) -#' } +#' #' @export getse <- function(L, inm = NA, depth = 2, useregex = FALSE, fun = NA) { diff --git a/R/lg.R b/R/lg.R index 9362a2ebdbf5071826f737f09a180e8fdacb94fa..c3087bc3ae41f3aebfb71b29871551e16b321389 100644 --- a/R/lg.R +++ b/R/lg.R @@ -118,7 +118,7 @@ lg.logical <- function(x, lagseq) { #' lg(X, "-h") #' #' # If not same length as columns in X, then it doesn't know how to lag -#' \donttest{lg(X, 1:2)} +#' \donttest{#lg(X, 1:2)} #' #' \dontshow{ #' if(!class(lg(data.frame(k1=1:10), 2)) == "data.frame"){stop("Trying to lag data.frame with 1 column, but return is not class data.frame")} diff --git a/R/plot_ts.R b/R/plot_ts.R index 97d059b70958609e5b6ff9921c8fe4b140143258..1ce50abbca67e91c02636f75ec00c906d0d1dc3c 100644 --- a/R/plot_ts.R +++ b/R/plot_ts.R @@ -62,13 +62,13 @@ #' #' # Use plotly #' \donttest{library(plotly) -#' L <- plot_ts(D, c("heatload","Ta"), kseq=c(1,24), usely=TRUE, xlab="Time", -#' ylabs=c("Heat (kW)","Temperature (C)")) +#' #L <- plot_ts(D, c("heatload","Ta"), kseq=c(1,24), usely=TRUE, xlab="Time", +#' # ylabs=c("Heat (kW)","Temperature (C)")) #' #' # From plotly the figures are returned and can be further manipulated #' # e.g. put the legend in the top by -#' L[[length(L)]] <- L[[length(L)]] %>% layout(legend = list(x = 100, y = 0.98)) -#' print(subplot(L, shareX=TRUE, nrows=length(L), titleY = TRUE)) +#' #L[[length(L)]] <- L[[length(L)]] %>% layout(legend = list(x = 100, y = 0.98)) +#' #print(subplot(L, shareX=TRUE, nrows=length(L), titleY = TRUE)) #' } #' #' @rdname plot_ts diff --git a/R/plotly_ts.R b/R/plotly_ts.R index 97c04458cca0c4ac5eee70b4ecafb813b12f4558..e133781d9bebfb90dfcb09caeae7773003e17e6c 100644 --- a/R/plotly_ts.R +++ b/R/plotly_ts.R @@ -17,10 +17,10 @@ #' @examples #' #' \donttest{ -#' D <- Dbuilding -#' plotly_ts(D, c("heatload","Ta"), kseq=c(1,24)) -#' plotly_ts(D, c("heatload","Ta"), kseq=c(1,24)) -#' plotly_ts(D, c("heatload","Ta$|Ta.obs$"), kseq=c(1,24)) +#' #D <- Dbuilding +#' #plotly_ts(D, c("heatload","Ta"), kseq=c(1,24)) +#' #plotly_ts(D, c("heatload","Ta"), kseq=c(1,24)) +#' #plotly_ts(D, c("heatload","Ta$|Ta.obs$"), kseq=c(1,24)) #' } #' #' @export diff --git a/make.R b/make.R index f1902eb42366ed26b603053641a5c5c68ee0ce28..8677269b1c44784ec094421975533d0b8ec36eff 100644 --- a/make.R +++ b/make.R @@ -1,43 +1,46 @@ +#---------------------------------------------------------------- # These packages must be installed +install.packages("Rcpp") +install.packages("R6") +install.packages("splines") +install.packages("digest") +# cpp matrix library +install.packages("RcppArmadillo") +# For develop install +install.packages("devtools") +install.packages("roxygen2") +# For testing and building vignettes +install.packages("rmarkdown") +install.packages("R.rsp") +install.packages("data.table") +install.packages("plotly") -# For building vignettes -# install.packages("R.rsp") -# cpp matrix library -# install.packages("RcppArmadillo") +#---------------------------------------------------------------- +# Go library(devtools) library(roxygen2) +# Load the package directly ## document() ## pack <- as.package("../onlineforecast") ## load_all(pack) -# Update NAMESPACE, use this function to export all functions! (with @export, but S3methods (e.g. print.lm) will not get exported, so change it to export) -## docit <- function(){ -## document() -## # Read -## nm <- "NAMESPACE" -## x <- scan(nm, what="character", sep="\n",blank.lines.skip=FALSE) -## # Manipulate x -## for(i in 1:length(x)){ -## if(length(grep("^S3method", x[i])) > 0){ -## x[i] <- gsub(",",".",gsub("S3method", "export", x[i])) -## } -## } -## # -## write(x, nm) -## } -## docit() # ---------------------------------------------------------------- -# Do also "R CMD check ../onlineforecast_1.0.0.tar.gz", it does give some other results! -#devtools::check() +# Misc +# +# Add new vignette +#usethis::use_vignette("setup-data") + # ---------------------------------------------------------------- -# For running tests in folder "tests/testthat/" +# Running tests in folder "tests/testthat/" +# # https://kbroman.org/pkg_primer/pages/tests.html # http://r-pkgs.had.co.nz/tests.html +# # Initialize first time the the testing framework #use_testthat() # Init new test @@ -48,16 +51,12 @@ library(roxygen2) #test() # # Run the examples -# run_examples() +#run_examples() # # Run tests in a single file # load_all(as.package("../onlineforecast")) # test_file("tests/testthat/test-rls-heat-load.R") -# Add new vignette -#usethis::use_vignette("setup-data") -#usethis::use_vignette("setup-and-use-model") -#usethis::use_vignette("forecast-evaluation") # ---------------------------------------------------------------- # Build the package (remember to rebuild vignettes for release) @@ -70,16 +69,59 @@ install.packages("../onlineforecast_1.0.0.tar.gz") library(onlineforecast) -# # ---------------------------------------------------------------- -# # Load the current version directly from the folder -# docit() -# load_all(as.package("../../onlineforecast"), export_all=FALSE) +# ---------------------------------------------------------------- +# Test before release +devtools::check() -# # What is exported? -# onlineforecast:: +devtools::check_built("../onlineforecast_1.0.0.tar.gz") +# Does give different results than check() above +system("R CMD check ../onlineforecast_1.0.0.tar.gz") + +# Test it on Windows with: +# https://win-builder.r-project.org/ -# ---------------------------------------------------------------- -# On release -# Test it on Windows with: https://win-builder.r-project.org/ +# Run another version of R +# see https://hub.docker.com/u/rocker + +# Open terminal and "sudo su" (needed for podman to access files) +# Run "podman run --rm -d -p 8787:8787 -e ROOT=TRUE -e PASSWORD=pw -v $(pwd):/home/rstudio rocker/rstudio" +# In browser go to "localhost:8787" +# login: rstudio and pw +# Open make.R +# Set working directory to this files directory +# Run installation of packages +# Make a cup of coffee +# Go to terminal and run: +# "sudo apt-get install xml2" +# "sudo apt-get install texlive" + +# Other versions with +# "podman run --rm -p 8787:8787 -e PASSWORD=pw -v /home/pbac/g:/home/rstudio/g rocker/rstudio:3.6.1" + + + + + + + +# ---------------------------------------------------------------- +# OLD, not exporting everything anymore +# +# Update NAMESPACE, use this function to export all functions! (with @export, but S3methods (e.g. print.lm) will not get exported, so change it to export) +## docit <- function(){ +## document() +## # Read +## nm <- "NAMESPACE" +## x <- scan(nm, what="character", sep="\n",blank.lines.skip=FALSE) +## # Manipulate x +## for(i in 1:length(x)){ +## if(length(grep("^S3method", x[i])) > 0){ +## x[i] <- gsub(",",".",gsub("S3method", "export", x[i])) +## } +## } +## # +## write(x, nm) +## } +## docit() diff --git a/src/Makevars b/src/Makevars deleted file mode 100644 index d3e3f4143c50ad561945e7c34e6fe45de229b498..0000000000000000000000000000000000000000 --- a/src/Makevars +++ /dev/null @@ -1,14 +0,0 @@ - -## With R 3.1.0 or later, you can uncomment the following line to tell R to -## enable compilation with C++11 (where available) -## -## Also, OpenMP support in Armadillo prefers C++11 support. However, for wider -## availability of the package we do not yet enforce this here. It is however -## recommended for client packages to set it. -## -## And with R 3.4.0, and RcppArmadillo 0.7.960.*, we turn C++11 on as OpenMP -## support within Armadillo prefers / requires it -CXX_STD = CXX11 - -PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) -PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) diff --git a/src/Makevars.win b/src/Makevars.win deleted file mode 100644 index d3e3f4143c50ad561945e7c34e6fe45de229b498..0000000000000000000000000000000000000000 --- a/src/Makevars.win +++ /dev/null @@ -1,14 +0,0 @@ - -## With R 3.1.0 or later, you can uncomment the following line to tell R to -## enable compilation with C++11 (where available) -## -## Also, OpenMP support in Armadillo prefers C++11 support. However, for wider -## availability of the package we do not yet enforce this here. It is however -## recommended for client packages to set it. -## -## And with R 3.4.0, and RcppArmadillo 0.7.960.*, we turn C++11 on as OpenMP -## support within Armadillo prefers / requires it -CXX_STD = CXX11 - -PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) -PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)