-
Notifications
You must be signed in to change notification settings - Fork 0
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
90fc2fb
commit 1febb9e
Showing
12 changed files
with
139 additions
and
26 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,7 +1,7 @@ | ||
Package: centrifugeR | ||
Type: Package | ||
Title: Non-Trivial Balance of Centrifuge Rotors | ||
Version: 0.1.4 | ||
Version: 0.1.5 | ||
Authors@R: person("Duy Nghia", "Pham", email = "[email protected]", | ||
role = c("aut", "cre"), comment = c(ORCID = "0000-0003-1349-1710")) | ||
Description: Find the numbers of tubes that can be loaded in centrifuge | ||
|
@@ -13,10 +13,10 @@ Depends: R (>= 3.6.0) | |
Imports: pracma (>= 2.2.9), grDevices, graphics, utils | ||
License: GPL-3 | ||
Encoding: UTF-8 | ||
RoxygenNote: 7.1.0 | ||
RoxygenNote: 7.1.1 | ||
NeedsCompilation: no | ||
Packaged: 2020-04-16 22:56:00 UTC; Nghia Pham | ||
Packaged: 2020-09-23 07:20:57 UTC; Nghia Pham | ||
Author: Duy Nghia Pham [aut, cre] (<https://orcid.org/0000-0003-1349-1710>) | ||
Maintainer: Duy Nghia Pham <[email protected]> | ||
Repository: CRAN | ||
Date/Publication: 2020-04-17 08:00:06 UTC | ||
Date/Publication: 2020-09-23 08:40:15 UTC |
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,14 +1,16 @@ | ||
d95115a83321f291c39f334c4745e400 *DESCRIPTION | ||
2feddedc1ccfe37fd6556794d484296f *NAMESPACE | ||
43db61f120dd6e76f18997a40171887d *R/centrifugeR-package.R | ||
ce853759f392760689d2046c6fb19fee *DESCRIPTION | ||
3af5fc3e6dfc5a06dbecb9f558084db0 *NAMESPACE | ||
fec74a6f6c2a159bd88f13136c33a65f *R/centrifugeR-package.R | ||
7b45d554c097f85b3ab182bd9557310e *R/rotorCheck.R | ||
65344e484e1ddbadb470d6a7d372a720 *R/rotorEqual.R | ||
cb42bcfdefd64e9b905c85320a9e6ed2 *R/rotorEqual.R | ||
c71d809258dea030959fcbeb08a7c591 *R/rotorSpeed.R | ||
4b6d974ac8b36bdf1798a86722f880a3 *R/rotorUnequal.R | ||
ac17fdef594c928cd753a572361bfa41 *R/zzz.R | ||
b6791096e96ffc85ae1f7b0dfdcf0f2c *R/rotorUnequal.R | ||
b9d5239b9c40116638086c4a78b75061 *R/rotorVerify.R | ||
72a264431206dd046d6f506f24e6f0c2 *R/zzz.R | ||
75abefbea9db81229f4d1aa8773fd523 *inst/CITATION | ||
c6c0ecfb0bb0f56c77c9908b83c1fb12 *man/centrifugeR-package.Rd | ||
e4ea5155ffa8a8932a1e9f4b86f24e2e *man/centrifugeR-package.Rd | ||
bb9e60d3dc45ecf2bbe9c09854ffdd96 *man/rotorCheck.Rd | ||
15d13414f51d8fc370379d2f3349cb38 *man/rotorEqual.Rd | ||
a33e22e27cef5d84c49b0f0b2ec657d8 *man/rotorEqual.Rd | ||
8c2bd025acf39a5c77376017773b2b69 *man/rotorSpeed.Rd | ||
7611e56bbdda41710997d276775ee8fc *man/rotorUnequal.Rd | ||
6b6bfbf5bd36611daf26344b569387a6 *man/rotorUnequal.Rd | ||
aa5a66e9cc172b129994243da008388e *man/rotorVerify.Rd |
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
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
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
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
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,55 @@ | ||
#' Verify Centrifuge Balance | ||
#' | ||
#' \code{rotorVerify} checks whether the rotor is balanced given the positions | ||
#' of tubes of equal mass. | ||
#' | ||
#' @param n an integer, the number of rotor buckets. | ||
#' @param pos an integer vector, the positions of tubes. | ||
#' | ||
#' @details The number of rotor buckets \code{n} ranges from \code{4} to | ||
#' \code{48}. The positions of tubes \code{pos} ranges from 1 to \code{n}. | ||
#' | ||
#' @return \code{rotorVerify} returns \code{1} if the rotor is balanced and | ||
#' \code{0} if the rotor is unbalanced. | ||
#' | ||
#' @references Johnsson M. Balancing a centrifuge. R-bloggers. 2016. Available | ||
#' from: \url{https://www.r-bloggers.com/2016/06/balancing-a-centrifuge/}. | ||
#' | ||
#' @seealso \code{\link{rotorCheck}} for checking centrifuge rotors. | ||
#' | ||
#' @examples | ||
#' rotorVerify(30, c(10, 20, 30)) | ||
#' rotorVerify(30, c(1, 11, 21, 4, 28)) | ||
#' | ||
#' @export | ||
rotorVerify <- function (n, pos) { | ||
if (n < 4 | n > 48) { | ||
stop("The rotor must have at least 4 buckets and no more than 48 buckets. \n") | ||
} | ||
k <- length(pos) | ||
if (k == 0 | k > n) { | ||
stop("The number of tubes must neither be 0 nor greater than the number of rotor buckets. \n") | ||
} | ||
if (sum(pos < 1 | pos > n | pos != floor(pos) | duplicated(pos)) > 0) { | ||
stop("The positions of tubes must be different integers ranging from 1 to n. \n") | ||
} | ||
prime <- unique(factors(n)) | ||
coeff <- mapply(seq, 0, n / prime, SIMPLIFY = FALSE) | ||
coeff.com <- do.call(expand.grid, coeff) | ||
linear <- apply(coeff.com, 1, function(x) dot(x, prime)) | ||
if (!k %in% linear | !(n - k) %in% linear) { | ||
stop(paste("CANNOT load", k, "tubes in a rotor with", n, "buckets. \n")) | ||
} | ||
p2c <- function(x){ | ||
theta <- (x - 1) * 2 * pi / n | ||
c(cos(theta), sin(theta)) | ||
} | ||
if (sum(abs(rowSums(sapply(pos, p2c))) < 10^-10) == 2) { | ||
message("The rotor is balanced") | ||
result <- 1 | ||
} else { | ||
message("The rotor is unbalanced") | ||
result <- 0 | ||
} | ||
result | ||
} |
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,4 +1,4 @@ | ||
.onAttach <- function(libname, pkgname) { | ||
packageStartupMessage("centrifugeR Copyright (C) 2019 Duy Nghia Pham") | ||
packageStartupMessage("centrifugeR Copyright (C) 2020 Duy Nghia Pham") | ||
packageStartupMessage("centrifugeR is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions.") | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.