Skip to content

Commit

Permalink
SH:
Browse files Browse the repository at this point in the history
  • Loading branch information
hojsgaard committed Oct 31, 2024
1 parent 37a194a commit 93031d2
Show file tree
Hide file tree
Showing 13 changed files with 504 additions and 778 deletions.
242 changes: 0 additions & 242 deletions R/api_array_parray.R

This file was deleted.

85 changes: 0 additions & 85 deletions R/api_array_pct.R

This file was deleted.

25 changes: 15 additions & 10 deletions R/api_array_properties.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,44 @@
#' @param obj Some R object.
#' @param a1,a2 Arrays with named dimnames.
#'
## #' @seealso \code{\link{is.named.array}}
## #' @seealso \code{\link{is_named_array}}
#' @examples
#' is.named.array( HairEyeColor )
#' is.named.array( matrix(1:4, nrow=2) )
#' is_named_array( HairEyeColor )
#' is_named_array( matrix(1:4, nrow=2) )
#' is_named_array_( HairEyeColor )
#' is_named_array_( matrix(1:4, nrow=2) )
#' is_number_vector_(1:4)
#' is_number_vector_(list(1:4))
#'
#' ar1 = tabNew(c("a", "b"), levels=c(2, 3))
#' ar2 = tabNew(c("c", "a"), levels=c(2, 2))
#' ar1 = tab_new(c("a", "b"), levels=c(2, 3))
#' ar2 = tab_new(c("c", "a"), levels=c(2, 2))
#' ar1
#' ar2
#' ## dimension a has levels a1,a2 in both ar1 and ar2.
#' # Hence we have a match.
#' dimnames_match(ar1, ar2)
#'
#' ar1 = tabNew(c("a", "b"), levels=c(2, 3))
#' ar2 = tabNew(c("c", "a"), levels=c(2, 3))
#' ar1 = tab_new(c("a", "b"), levels=c(2, 3))
#' ar2 = tab_new(c("c", "a"), levels=c(2, 3))
#' ar1
#' ar2
#' ## dimension a has levels a1,a2 in ar1 and levels a1,a2,a3 in ar2.
#' # Hence we do not have a match.
#' dimnames_match(ar1, ar2)
#'
#' ar2 = tabNew(c("c", "a"), levels=list(c=c("c1", "c2"), a=c("a2", "a1")))
#' ar2 = tab_new(c("c", "a"), levels=list(c=c("c1", "c2"), a=c("a2", "a1")))
#' ar2
#' ## dimension a has levels a1,a2 in ar1 and levels a2,a1 in ar2.
#' # Hence we do not have a match.
#' dimnames_match(ar1, ar2)

#' @export
#' @rdname api-array-properties
is_named_array <- is_named_array_

## FIXME: Needed for gRain
#' @export
#' @rdname api-array-properties
is.named.array <- is_named_array_

#' @export
Expand All @@ -62,9 +67,9 @@ is_dimnames_ <- is_dimnames_
#' @export
#' @rdname api-array-properties
dimnames_match <- function( a1, a2 ){
if ( !is.named.array( a1 ) )
if ( !is_named_array( a1 ) )
stop("'a1' is not a named array \n")
if ( !is.named.array( a2 ) )
if ( !is_named_array( a2 ) )
stop("'a2' is not a named array \n")

dn1 <- dimnames( a1 )
Expand Down
Loading

0 comments on commit 93031d2

Please sign in to comment.