Skip to content

Commit

Permalink
Merge pull request #24 from weirichs/check_tablePattern
Browse files Browse the repository at this point in the history
assertion for tablePattern
  • Loading branch information
weirichs committed Mar 27, 2024
2 parents 8c528cb + 4706380 commit 1aeca82
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/tablePattern.r
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
### z.B. table.muster(a, c(1,5,7,8,9)) sucht, wie oft jede Zahl in "mustervektor" in "vektor" vorkommt
### Warnung, wenn zusaetzliche Zahlen in Vektor stehen
tablePattern <- function(x, pattern = NULL, weights, na.rm = TRUE, useNA = c("no", "ifany", "always")) {
checkmate::assert_vector(x)
checkmate::assert_vector(pattern, null.ok = TRUE, unique = TRUE)
if(length(pattern)>0) {
additional.values <- na.omit( setdiff(x,pattern))
if( length( additional.values ) > 0 ) {
Expand All @@ -20,6 +22,7 @@ tablePattern <- function(x, pattern = NULL, weights, na.rm = TRUE, useNA = c("no
if(missing(weights)) {
Table <- table(y, useNA =useNA )
} else {
checkmate::assert_numeric(weights, len = length(x))
if ( length(notInData) > 0) {
x <- c(as.character(x), as.character(notInData))
weights<- c(weights, rep(0, length(notInData)))
Expand Down

0 comments on commit 1aeca82

Please sign in to comment.