tex.catwitherror does not work well with vectors
There should probably be some internal loops, such that vector-valued quantities can be dealt with. At present, this fails because the conditionals don't play nice with vectors of x and dx.
There should probably be some internal loops, such that vector-valued quantities can be dealt with. At present, this fails because the conditionals don't play nice with vectors of
xanddx.
well, it can be used with apply...!
well, it can be used with apply...!
That's true, but it cannot be used with dplyr::mutate like so:
data <- data.frame(val = [...], err = [...])
data <- dplyr::mutate(data, tex = tex.catwitherror(x = val, dx = err))
which is a really handy function for adding new columns to data frames based on existing columns.
I always just use mapply:
mutate(tex = mapply(tex.catwitherror, val, err))
It would be trivial to have a the current non-vectorized version as tex.catwitherror.scalar and then have a new tex.catwitherror which just calles the implementation with mapply. The problem is that currently it is allowed to pass value and error as a two-element vector as the first argument. This would become inconsistent then.
It would be trivial to have a the current non-vectorized version as
tex.catwitherror.scalarand then have a newtex.catwitherrorwhich just calles the implementation withmapply. The problem is that currently it is allowed to pass value and error as a two-element vector as the first argument. This would become inconsistent then.
Well, rather the new one would get a different name, wouldn't it?