Commit f0a2bd3e authored by Ahmad Alkadri's avatar Ahmad Alkadri 🎧

Added a function (subsetmat) and edited the help page of the others.

parent 3801ac57
...@@ -53,3 +53,33 @@ library(rterahertz) ...@@ -53,3 +53,33 @@ library(rterahertz)
?correctingmatTHz ?correctingmatTHz
?correctingmatTHz ?correctingmatTHz
library(rterahertz) library(rterahertz)
?median
?sd
library(rterahertz)
?sdareamat
library(rterahertz)
?sdareamat
m <- matrix(rnorm(100, mean = 0, sd = 1), nrow = 10, ncol = 10)
sdarea <- sdareamat(m, rowmin = 1, rowmax = 3, colmin = 2, colmax = 5)
View(m)
m[1:3,2:5]
sd(m[1:3,2:5])
library(rterahertz)
m <- matrix(rnorm(100, mean = 0, sd = 1), nrow = 10, ncol = 10)
sdarea <- sdareamat(m, rowmin = 1, rowmax = 3, colmin = 2, colmax = 5)
sd(m[1:3,2:5])
?meanareamat
m <- matrix(rnorm(100, mean = 0, sd = 1), nrow = 10, ncol = 10)
meanarea <- meanareamat(m, rowmin = 1, rowmax = 3, colmin = 2, colmax = 5)
mean(m[1:3,2:5])
m <- matrix(rnorm(100, mean = 0, sd = 1), nrow = 10, ncol = 10)
medianarea <- medianareamat(m, rowmin = 1, rowmax = 3, colmin = 2, colmax = 5)
median(m[1:3,2:5])
library(rterahertz)
?sdareamat
library(rterahertz)
library(rterahertz)
?sdareamat
library(rterahertz)
?sdareamat
library(rterahertz)
{ {
"path" : "~/Documents/These/Works/Current models/R_packages/rterahertz/R", "path" : "~/Documents/These/Works/Current models/R_packages/rterahertz",
"sortOrder" : [ "sortOrder" : [
{ {
"ascending" : true, "ascending" : true,
......
{ {
"activeTab" : 1 "activeTab" : 3
} }
\ No newline at end of file
{ {
"TabSet1" : 3, "TabSet1" : 3,
"TabSet2" : 3, "TabSet2" : 4,
"TabZoom" : { "TabZoom" : {
} }
} }
\ No newline at end of file
build-last-errors="[]" build-last-errors="[]"
build-last-errors-base-dir="~/Documents/These/Works/Current models/R_packages/rterahertz/" build-last-errors-base-dir="~/Documents/These/Works/Current models/R_packages/rterahertz/"
build-last-outputs="[{\"output\":\"==> devtools::document(roclets = c('rd', 'collate', 'namespace'))\\n\\n\",\"type\":0},{\"output\":\"Updating rterahertz documentation\\n\",\"type\":2},{\"output\":\"Loading rterahertz\\n\",\"type\":2},{\"output\":\"Warning: The existing 'NAMESPACE' file was not generated by roxygen2, and will not be overwritten.\\n\",\"type\":2},{\"output\":\"Documentation completed\\n\\n\",\"type\":1},{\"output\":\"==> R CMD INSTALL --preclean --no-multiarch --with-keep.source rterahertz\\n\\n\",\"type\":0},{\"output\":\"* installing to library ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library’\\n\",\"type\":1},{\"output\":\"* installing *source* package ‘rterahertz’ ...\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** using staged installation\\n\",\"type\":1},{\"output\":\"** R\\n\",\"type\":1},{\"output\":\"** byte-compile and prepare package for lazy loading\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** help\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"*** installing help indices\\n\",\"type\":1},{\"output\":\"** building package indices\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** testing if installed package can be loaded from temporary location\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** testing if installed package can be loaded from final location\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** testing if installed package keeps a record of temporary installation path\\n\",\"type\":1},{\"output\":\"* DONE (rterahertz)\\n\",\"type\":1},{\"output\":\"\",\"type\":1}]" build-last-outputs="[{\"output\":\"==> devtools::document(roclets = c('rd', 'collate', 'namespace'))\\n\\n\",\"type\":0},{\"output\":\"Updating rterahertz documentation\\n\",\"type\":2},{\"output\":\"Loading rterahertz\\n\",\"type\":2},{\"output\":\"Warning: The existing 'NAMESPACE' file was not generated by roxygen2, and will not be overwritten.\\n\",\"type\":2},{\"output\":\"Documentation completed\\n\\n\",\"type\":1},{\"output\":\"==> R CMD INSTALL --no-multiarch --with-keep.source rterahertz\\n\\n\",\"type\":0},{\"output\":\"* installing to library ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library’\\n\",\"type\":1},{\"output\":\"* installing *source* package ‘rterahertz’ ...\\n\",\"type\":1},{\"output\":\"** using staged installation\\n\",\"type\":1},{\"output\":\"** R\\n\",\"type\":1},{\"output\":\"** byte-compile and prepare package for lazy loading\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** help\\n\",\"type\":1},{\"output\":\"*** installing help indices\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** building package indices\\n\",\"type\":1},{\"output\":\"** testing if installed package can be loaded from temporary location\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** testing if installed package can be loaded from final location\\n\",\"type\":1},{\"output\":\"\",\"type\":1},{\"output\":\"** testing if installed package keeps a record of temporary installation path\\n\",\"type\":1},{\"output\":\"* DONE (rterahertz)\\n\",\"type\":1},{\"output\":\"\",\"type\":1}]"
compile_pdf_state="{\"errors\":[],\"output\":\"\",\"running\":false,\"tab_visible\":false,\"target_file\":\"\"}" compile_pdf_state="{\"errors\":[],\"output\":\"\",\"running\":false,\"tab_visible\":false,\"target_file\":\"\"}"
files.monitored-path="" files.monitored-path=""
find-in-files-state="{\"handle\":\"\",\"input\":\"\",\"path\":\"\",\"regex\":true,\"results\":{\"file\":[],\"line\":[],\"lineValue\":[],\"matchOff\":[],\"matchOn\":[]},\"running\":false}" find-in-files-state="{\"handle\":\"\",\"input\":\"\",\"path\":\"\",\"regex\":true,\"results\":{\"file\":[],\"line\":[],\"lineValue\":[],\"matchOff\":[],\"matchOn\":[]},\"running\":false}"
......
Package: rterahertz Package: rterahertz
Type: Package Type: Package
Title: R-Terahertz Title: R-Terahertz
Version: 0.1.0 Version: 0.1.2
Authors@R: Authors@R:
person(given = "Ahmad", person(given = "Ahmad",
family = "Alkadri", family = "Alkadri",
......
...@@ -5,21 +5,17 @@ ...@@ -5,21 +5,17 @@
#' 2nd column, 1st row to 3rd row, 5th column, we'll get the values of this smaller matrix #' 2nd column, 1st row to 3rd row, 5th column, we'll get the values of this smaller matrix
#' (3x4 to be precise) and then we'll calculate the mean of all of them. #' (3x4 to be precise) and then we'll calculate the mean of all of them.
#' #'
#' @usage meanareamat(m, rowmin, rowmax, colmin, colmax) #' @usage meanareamat(m, rowmin=1, rowmax, colmin=1, colmax)
#' #'
#' @param m A matrix object #' @param m A matrix object
#' #'
#' @param rowmin The first row for subsetting. Taking an example from the description above, #' @param rowmin The first row for subsetting. Default value is 1.
#' the rowmin is 1
#' #'
#' @param rowmax The last row for subsetting. Taking an example from the description above, #' @param rowmax The last row for subsetting.
#' the rowmax is 3
#' #'
#' @param colmin The first column for subsetting. Taking an example from the description above, #' @param colmin The first column for subsetting. Default value is 1.
#' the colmin is 2
#' #'
#' @param colmax The last column for subsetting. Taking an example from the description above, #' @param colmax The last column for subsetting.
#' the colmax is 5
#' #'
#' @return The mean value of the subsetted area of matrix m #' @return The mean value of the subsetted area of matrix m
#' #'
...@@ -27,7 +23,7 @@ ...@@ -27,7 +23,7 @@
#' m <- matrix(rnorm(100, mean = 0, sd = 1), nrow = 10, ncol = 10) #' m <- matrix(rnorm(100, mean = 0, sd = 1), nrow = 10, ncol = 10)
#' meanarea <- meanareamat(m, rowmin = 1, rowmax = 3, colmin = 2, colmax = 5) #' meanarea <- meanareamat(m, rowmin = 1, rowmax = 3, colmin = 2, colmax = 5)
meanareamat <- function(m, rowmin, rowmax, colmin, colmax){ meanareamat <- function(m, rowmin=1, rowmax, colmin=1, colmax){
m_n <- m[rowmin:rowmax,colmin:colmax] m_n <- m[rowmin:rowmax,colmin:colmax]
...@@ -46,21 +42,17 @@ meanareamat <- function(m, rowmin, rowmax, colmin, colmax){ ...@@ -46,21 +42,17 @@ meanareamat <- function(m, rowmin, rowmax, colmin, colmax){
#' 2nd column, 1st row to 3rd row, 5th column, we'll get the values of this smaller matrix #' 2nd column, 1st row to 3rd row, 5th column, we'll get the values of this smaller matrix
#' (3x4 to be precise) and then we'll calculate the median of all of them. #' (3x4 to be precise) and then we'll calculate the median of all of them.
#' #'
#' @usage medianareamat(m, rowmin, rowmax, colmin, colmax) #' @usage medianareamat(m, rowmin=1, rowmax, colmin=1, colmax)
#' #'
#' @param m A matrix object #' @param m A matrix object
#' #'
#' @param rowmin The first row for subsetting. Taking an example from the description above, #' @param rowmin The first row for subsetting. Default value is 1.
#' the rowmin is 1
#' #'
#' @param rowmax The last row for subsetting. Taking an example from the description above, #' @param rowmax The last row for subsetting.
#' the rowmax is 3
#' #'
#' @param colmin The first column for subsetting. Taking an example from the description above, #' @param colmin The first column for subsetting. Default value is 1.
#' the colmin is 2
#' #'
#' @param colmax The last column for subsetting. Taking an example from the description above, #' @param colmax The last column for subsetting.
#' the colmax is 5
#' #'
#' @return The median value of the subsetted area of matrix m #' @return The median value of the subsetted area of matrix m
#' #'
...@@ -68,7 +60,7 @@ meanareamat <- function(m, rowmin, rowmax, colmin, colmax){ ...@@ -68,7 +60,7 @@ meanareamat <- function(m, rowmin, rowmax, colmin, colmax){
#' m <- matrix(rnorm(100, mean = 0, sd = 1), nrow = 10, ncol = 10) #' m <- matrix(rnorm(100, mean = 0, sd = 1), nrow = 10, ncol = 10)
#' medianarea <- medianareamat(m, rowmin = 1, rowmax = 3, colmin = 2, colmax = 5) #' medianarea <- medianareamat(m, rowmin = 1, rowmax = 3, colmin = 2, colmax = 5)
medianareamat <- function(m, rowmin, rowmax, colmin, colmax){ medianareamat <- function(m, rowmin=1, rowmax, colmin=1, colmax){
m_n <- m[rowmin:rowmax,colmin:colmax] m_n <- m[rowmin:rowmax,colmin:colmax]
...@@ -87,21 +79,17 @@ medianareamat <- function(m, rowmin, rowmax, colmin, colmax){ ...@@ -87,21 +79,17 @@ medianareamat <- function(m, rowmin, rowmax, colmin, colmax){
#' 2nd column, 1st row to 3rd row, 5th column, we'll get the values of this smaller matrix #' 2nd column, 1st row to 3rd row, 5th column, we'll get the values of this smaller matrix
#' (3x4 to be precise) and then we'll calculate the standard deviation of all of them. #' (3x4 to be precise) and then we'll calculate the standard deviation of all of them.
#' #'
#' @usage sdareamat(m, rowmin, rowmax, colmin, colmax) #' @usage sdareamat(m, rowmin=1, rowmax, colmin=1, colmax)
#' #'
#' @param m A matrix object #' @param m A matrix object
#' #'
#' @param rowmin The first row for subsetting. Taking an example from the description above, #' @param rowmin The first row for subsetting. Default value is 1.
#' the rowmin is 1
#' #'
#' @param rowmax The last row for subsetting. Taking an example from the description above, #' @param rowmax The last row for subsetting.
#' the rowmax is 3
#' #'
#' @param colmin The first column for subsetting. Taking an example from the description above, #' @param colmin The first column for subsetting. Default value is 1.
#' the colmin is 2
#' #'
#' @param colmax The last column for subsetting. Taking an example from the description above, #' @param colmax The last column for subsetting.
#' the colmax is 5
#' #'
#' @return The standard deviation value of the subsetted area of matrix m #' @return The standard deviation value of the subsetted area of matrix m
#' #'
...@@ -109,7 +97,7 @@ medianareamat <- function(m, rowmin, rowmax, colmin, colmax){ ...@@ -109,7 +97,7 @@ medianareamat <- function(m, rowmin, rowmax, colmin, colmax){
#' m <- matrix(rnorm(100, mean = 0, sd = 1), nrow = 10, ncol = 10) #' m <- matrix(rnorm(100, mean = 0, sd = 1), nrow = 10, ncol = 10)
#' sdarea <- sdareamat(m, rowmin = 1, rowmax = 3, colmin = 2, colmax = 5) #' sdarea <- sdareamat(m, rowmin = 1, rowmax = 3, colmin = 2, colmax = 5)
sdareamat <- function(m, rowmin, rowmax, colmin, colmax){ sdareamat <- function(m, rowmin=1, rowmax, colmin=1, colmax){
m_n <- m[rowmin:rowmax,colmin:colmax] m_n <- m[rowmin:rowmax,colmin:colmax]
...@@ -120,3 +108,33 @@ sdareamat <- function(m, rowmin, rowmax, colmin, colmax){ ...@@ -120,3 +108,33 @@ sdareamat <- function(m, rowmin, rowmax, colmin, colmax){
return(sd_m) return(sd_m)
} }
#' Function to subset a matrix.
#'
#' @description A function for subsetting a matrix.
#'
#' @usage subsetmat(m, rowmin=1, rowmax, colmin=1, colmax)
#'
#' @param m A matrix object
#'
#' @param rowmin The first row for subsetting. Default value is 1.
#'
#' @param rowmax The last row for subsetting.
#'
#' @param colmin The first column for subsetting. Default value is 1.
#'
#' @param colmax The last column for subsetting.
#'
#' @return The standard deviation value of the subsetted area of matrix m
#'
#' @examples
#' m <- matrix(rnorm(100, mean = 0, sd = 1), nrow = 10, ncol = 10)
#' m_part <- subsetmat(m, rowmin = 1, rowmax = 3, colmin = 2, colmax = 5)
subsetmat <- function(m, rowmin=1, rowmax, colmin=1, colmax){
m_n <- m[rowmin:rowmax,colmin:colmax]
return(m_n)
}
...@@ -4,22 +4,18 @@ ...@@ -4,22 +4,18 @@
\alias{meanareamat} \alias{meanareamat}
\title{Function for getting the mean value of an area on a matrix.} \title{Function for getting the mean value of an area on a matrix.}
\usage{ \usage{
meanareamat(m, rowmin, rowmax, colmin, colmax) meanareamat(m, rowmin=1, rowmax, colmin=1, colmax)
} }
\arguments{ \arguments{
\item{m}{A matrix object} \item{m}{A matrix object}
\item{rowmin}{The first row for subsetting. Taking an example from the description above, \item{rowmin}{The first row for subsetting. Default value is 1.}
the rowmin is 1}
\item{rowmax}{The last row for subsetting. Taking an example from the description above, \item{rowmax}{The last row for subsetting.}
the rowmax is 3}
\item{colmin}{The first column for subsetting. Taking an example from the description above, \item{colmin}{The first column for subsetting. Default value is 1.}
the colmin is 2}
\item{colmax}{The last column for subsetting. Taking an example from the description above, \item{colmax}{The last column for subsetting.}
the colmax is 5}
} }
\value{ \value{
The mean value of the subsetted area of matrix m The mean value of the subsetted area of matrix m
......
...@@ -4,22 +4,18 @@ ...@@ -4,22 +4,18 @@
\alias{medianareamat} \alias{medianareamat}
\title{Function for getting the median value of an area on a matrix.} \title{Function for getting the median value of an area on a matrix.}
\usage{ \usage{
medianareamat(m, rowmin, rowmax, colmin, colmax) medianareamat(m, rowmin=1, rowmax, colmin=1, colmax)
} }
\arguments{ \arguments{
\item{m}{A matrix object} \item{m}{A matrix object}
\item{rowmin}{The first row for subsetting. Taking an example from the description above, \item{rowmin}{The first row for subsetting. Default value is 1.}
the rowmin is 1}
\item{rowmax}{The last row for subsetting. Taking an example from the description above, \item{rowmax}{The last row for subsetting.}
the rowmax is 3}
\item{colmin}{The first column for subsetting. Taking an example from the description above, \item{colmin}{The first column for subsetting. Default value is 1.}
the colmin is 2}
\item{colmax}{The last column for subsetting. Taking an example from the description above, \item{colmax}{The last column for subsetting.}
the colmax is 5}
} }
\value{ \value{
The median value of the subsetted area of matrix m The median value of the subsetted area of matrix m
......
...@@ -4,22 +4,18 @@ ...@@ -4,22 +4,18 @@
\alias{sdareamat} \alias{sdareamat}
\title{Function for getting the standard deviation value of an area on a matrix.} \title{Function for getting the standard deviation value of an area on a matrix.}
\usage{ \usage{
sdareamat(m, rowmin, rowmax, colmin, colmax) sdareamat(m, rowmin=1, rowmax, colmin=1, colmax)
} }
\arguments{ \arguments{
\item{m}{A matrix object} \item{m}{A matrix object}
\item{rowmin}{The first row for subsetting. Taking an example from the description above, \item{rowmin}{The first row for subsetting. Default value is 1.}
the rowmin is 1}
\item{rowmax}{The last row for subsetting. Taking an example from the description above, \item{rowmax}{The last row for subsetting.}
the rowmax is 3}
\item{colmin}{The first column for subsetting. Taking an example from the description above, \item{colmin}{The first column for subsetting. Default value is 1.}
the colmin is 2}
\item{colmax}{The last column for subsetting. Taking an example from the description above, \item{colmax}{The last column for subsetting.}
the colmax is 5}
} }
\value{ \value{
The standard deviation value of the subsetted area of matrix m The standard deviation value of the subsetted area of matrix m
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/operationareamat.R
\name{subsetmat}
\alias{subsetmat}
\title{Function to subset a matrix.}
\usage{
subsetmat(m, rowmin=1, rowmax, colmin=1, colmax)
}
\arguments{
\item{m}{A matrix object}
\item{rowmin}{The first row for subsetting. Default value is 1.}
\item{rowmax}{The last row for subsetting.}
\item{colmin}{The first column for subsetting. Default value is 1.}
\item{colmax}{The last column for subsetting.}
}
\value{
The standard deviation value of the subsetted area of matrix m
}
\description{
A function for subsetting a matrix.
}
\examples{
m <- matrix(rnorm(100, mean = 0, sd = 1), nrow = 10, ncol = 10)
m_part <- subsetmat(m, rowmin = 1, rowmax = 3, colmin = 2, colmax = 5)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment