Skip to content

Commit

Permalink
updating
Browse files Browse the repository at this point in the history
  • Loading branch information
Fgazzelloni committed Mar 6, 2024
1 parent ef28fca commit 2ba79e7
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
^hmsidwR\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
^README\.Rmd$
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2024
COPYRIGHT HOLDER: hmsidwR authors
21 changes: 21 additions & 0 deletions LICENSE.md
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.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Generated by roxygen2: do not edit by hand

export(lmforecast)
22 changes: 22 additions & 0 deletions R/lmforecast.R
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)
}



42 changes: 42 additions & 0 deletions README.Rmd
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
```


30 changes: 30 additions & 0 deletions README.md
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
```
42 changes: 42 additions & 0 deletions building_blocks.R
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

27 changes: 27 additions & 0 deletions man/lmforecast.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions tests/testthat.R
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")
13 changes: 13 additions & 0 deletions tests/testthat/test-lmforecast.R
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
)
)
})

0 comments on commit 2ba79e7

Please sign in to comment.