-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef28fca
commit 2ba79e7
Showing
11 changed files
with
214 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
^hmsidwR\.Rproj$ | ||
^\.Rproj\.user$ | ||
^LICENSE\.md$ | ||
^README\.Rmd$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
YEAR: 2024 | ||
COPYRIGHT HOLDER: hmsidwR authors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# MIT License | ||
|
||
Copyright (c) 2024 hmsidwR authors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(lmforecast) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#' lmforecast function | ||
#' | ||
#' @param x A numeric vector, identifying the covariate of the model | ||
#' @param a A numeric vector, The intercept | ||
#' @param m A numeric vector, The slope, or the betas estimated values | ||
#' @param e A numeric vector, The error | ||
#' | ||
#' @return A dataframe containing the vector with the estimation, and the original data | ||
#' @export | ||
#' | ||
#' @examples | ||
#' x=rnorm(n = 50,mean = 0,sd = 1) | ||
#' lmforecast(x=x, a=0.1, m=dunif(x,min = 0.02,max = 1),e=rnorm(length(x),mean = 0,sd = 1)) | ||
|
||
lmforecast <- function(x,a,m,e) { | ||
stopifnot(is.numeric(x), length(x) >= 1) | ||
pred= a+m*x+e | ||
data.frame(pred,x,error=e) | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
output: github_document | ||
--- | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
```{r, include = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>", | ||
fig.path = "man/figures/README-", | ||
out.width = "100%" | ||
) | ||
``` | ||
|
||
# hmsidwR - Health Metrics and the Spread of Infectious Diseases with R | ||
|
||
<!-- badges: start --> | ||
<!-- badges: end --> | ||
|
||
The goal of `{hmsidwR}` is to provide the set of data used in the **Health Metrics and the Spread of Infectious Diseases | ||
Machine Learning Applications and Spatial Modeling Analysis with R** book. | ||
|
||
## Installation | ||
|
||
You can install the development version of hmsidwR from [GitHub](https://github.com/) with: | ||
|
||
``` r | ||
# install.packages("devtools") | ||
devtools::install_github("Fgazzelloni/hmsidwR") | ||
``` | ||
|
||
## Example | ||
|
||
This is a basic example which shows you how to solve a common problem: | ||
|
||
```{r example} | ||
library(hmsidwR) | ||
## basic example code | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
# hmsidwR - Health Metrics and the Spread of Infectious Diseases with R | ||
|
||
<!-- badges: start --> | ||
<!-- badges: end --> | ||
|
||
The goal of `{hmsidwR}` is to provide the set of data used in the | ||
**Health Metrics and the Spread of Infectious Diseases Machine Learning | ||
Applications and Spatial Modeling Analysis with R** book. | ||
|
||
## Installation | ||
|
||
You can install the development version of hmsidwR from | ||
[GitHub](https://github.com/) with: | ||
|
||
``` r | ||
# install.packages("devtools") | ||
devtools::install_github("Fgazzelloni/hmsidwR") | ||
``` | ||
|
||
## Example | ||
|
||
This is a basic example which shows you how to solve a common problem: | ||
|
||
``` r | ||
library(hmsidwR) | ||
## basic example code | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,48 @@ | ||
## Create a package | ||
## check the package's name availability | ||
library(available) | ||
available::available("hmsidwR") | ||
|
||
library(devtools) | ||
library(usethis) | ||
usethis::create_package("~/Documents/R/AAA_packages/hmsidwR") | ||
usethis::use_git() | ||
|
||
## Function Documentation | ||
usethis::use_r("lmforecast") | ||
|
||
## restart and load the function | ||
devtools::load_all() | ||
|
||
## check the package status | ||
devtools::check() | ||
|
||
## type ctrl . to access the DESCRIPTION file to customize | ||
## add the licence | ||
usethis::use_mit_license() | ||
|
||
## add documentation of the function | ||
# head over the function file and --> code--> Insert roxygen skeleton | ||
devtools::document() | ||
|
||
## Install the package (Cmd + Shift + B) | ||
devtools::install() | ||
|
||
## install testthat to check functions | ||
usethis::use_testthat() | ||
# then fill up the test_that() function with expected output | ||
devtools::test() | ||
|
||
## use github | ||
usethis::use_github() | ||
|
||
## add a readme | ||
usethis::use_readme_rmd() | ||
|
||
## build the readme | ||
devtools::build_readme() | ||
## then check and install | ||
|
||
|
||
## Data | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This file is part of the standard setup for testthat. | ||
# It is recommended that you do not modify it. | ||
# | ||
# Where should you do additional test configuration? | ||
# Learn more about the roles of various files in: | ||
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview | ||
# * https://testthat.r-lib.org/articles/special-files.html | ||
|
||
library(testthat) | ||
library(hmsidwR) | ||
|
||
test_check("hmsidwR") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
test_that("lmforecast make prediction", { | ||
expect_equal( | ||
lmforecast(x=c(1), | ||
a=0.1, | ||
m=0.5, | ||
e=0.01), | ||
data.frame( | ||
pred=0.61, | ||
x =1, | ||
error=0.01 | ||
) | ||
) | ||
}) |