Adrogué
Cc: r-h...@stat.math.ethz.ch
Subject: Re: [R] get caller's name
On 03/02/2011 10:27 AM, Ernest Adrogué wrote:
Hi,
Suppose a function that checks an object:
stop.if.dims<- function(x) {
if (! is.null(dim(x))) {
stop("cannot handle dimensional data")
}
}
Thi
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan Murdoch
> Sent: Friday, February 04, 2011 6:03 AM
> To: Ernest Adrogué
> Cc: r-h...@stat.math.ethz.ch
> Subject: Re: [R] get caller's name
&
On 03/02/2011 10:27 AM, Ernest Adrogué wrote:
Hi,
Suppose a function that checks an object:
stop.if.dims<- function(x) {
if (! is.null(dim(x))) {
stop("cannot handle dimensional data")
}
}
This would be used by other functions that can only work with
dimensionless objects. The proble
3/02/11 @ 14:30 (-0200), Henrique Dallazuanna escriu:
> Try this:
>
> g <- function(.x) tryCatch(stop.if.dims(.x), error=function(e)sprintf("Error
> in %s: %s", deparse(sys.call(1)), e$message))
> g(rbind(2, 3))
This is it. Thanks!
Cheers.
--
Ernest
__
3/02/11 @ 11:25 (-0500), David Winsemius escriu:
> On Feb 3, 2011, at 10:27 AM, Ernest Adrogué wrote:
>
> >Hi,
> >Suppose a function that checks an object:
> >
> >stop.if.dims <- function(x) {
> > if (! is.null(dim(x))) {
> > stop("cannot handle dimensional data")
> > }
> >}
> >
>
> > mtx <- m
Try this:
g <- function(.x) tryCatch(stop.if.dims(.x), error=function(e)sprintf("Error
in %s: %s", deparse(sys.call(1)), e$message))
g(rbind(2, 3))
2011/2/3 Ernest Adrogué
> Hi,
> Suppose a function that checks an object:
>
> stop.if.dims <- function(x) {
> if (! is.null(dim(x))) {
>stop(
On Feb 3, 2011, at 10:27 AM, Ernest Adrogué wrote:
Hi,
Suppose a function that checks an object:
stop.if.dims <- function(x) {
if (! is.null(dim(x))) {
stop("cannot handle dimensional data")
}
}
> mtx <- matrix(c(1,0,0,1), 2)
> stop.if.dims <- function(x) { objname <- deparse(substitut
Hi,
Suppose a function that checks an object:
stop.if.dims <- function(x) {
if (! is.null(dim(x))) {
stop("cannot handle dimensional data")
}
}
This would be used by other functions that can only work with
dimensionless objects. The problem is the error message would need to
include the n
8 matches
Mail list logo