From 307dfdcc42a8adf6edf0718ab8a2efeefc64c152 Mon Sep 17 00:00:00 2001 From: Zack-83 Date: Thu, 12 Jul 2018 14:01:00 +0200 Subject: [PATCH] First commitment --- .Rbuildignore | 2 ++ .gitignore | 4 ++++ DESCRIPTION | 11 +++++++++++ NAMESPACE | 1 + R/center.R | 17 +++++++++++++++++ R/rescale.R | 12 ++++++++++++ maRgheRitaR.Rproj | 20 ++++++++++++++++++++ 7 files changed, 67 insertions(+) create mode 100644 .Rbuildignore create mode 100644 .gitignore create mode 100644 DESCRIPTION create mode 100644 NAMESPACE create mode 100644 R/center.R create mode 100644 R/rescale.R create mode 100644 maRgheRitaR.Rproj diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..13e458c --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,2 @@ +^.*\.Rproj$ +^\.Rproj\.user$ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d44df33 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..83934cd --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,11 @@ +Package: maRgheRitaR +Type: Package +Title: What the Package Does (Title Case) +Version: 0.1.0 +Author: Who wrote it +Maintainer: The package maintainer +Description: More about what it does (maybe more than one line) + Use four spaces when indenting paragraphs within the Description. +License: What license is it under? +Encoding: UTF-8 +LazyData: true \ No newline at end of file diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..40ea8e2 --- /dev/null +++ b/NAMESPACE @@ -0,0 +1 @@ +exportPattern("^[[:alpha:]]+") diff --git a/R/center.R b/R/center.R new file mode 100644 index 0000000..3542987 --- /dev/null +++ b/R/center.R @@ -0,0 +1,17 @@ +#' Centering datasets +#' +#' Some more description +#' +#' And even more +#' +#' @param dataset The numeric vector to be centered +#' @param desired The numeric midpoint value around which the data will be centered +#' +#' @return A new vector containing the original data centered around the desired values +#' +#' @examples +# center(c(1,2,3),0) # should return -1 0 1 +# center(c(4,5,6),2) # should return 1 2 3 +center <- function(dataset, desired) { + dataset - mean(dataset) + desired +} diff --git a/R/rescale.R b/R/rescale.R new file mode 100644 index 0000000..1ee7405 --- /dev/null +++ b/R/rescale.R @@ -0,0 +1,12 @@ +#' Rescaling datasets +#' +#' @param v A numeric vector +#' +#' @return A new numeric vector, rescaled from the input vector to the range of 0 to 1 +#' +#' @examples +#' rescale(c(1,2,3)) # [1] 0.0 0.5 1.0 +#' rescale(c(1,2,3,4,5)) # [1] 0.00 0.25 0.50 0.75 1.00 +rescale <- function(v) { + (v - min(v)) / (max(v) - min(v)) +} diff --git a/maRgheRitaR.Rproj b/maRgheRitaR.Rproj new file mode 100644 index 0000000..b9255bc --- /dev/null +++ b/maRgheRitaR.Rproj @@ -0,0 +1,20 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source