[R] intervals from cut() as numerics?
Gavin Simpson
gavin.simpson at ucl.ac.uk
Mon May 22 18:18:31 CEST 2006
On Sat, 2006-05-20 at 15:44 +0200, Dimitrios Rizopoulos wrote:
> as an alternative, you can have a look inside cut.default and use the
> part that produces the breaks, i.e.,
>
> breaks <- 10
> groups <- cut(x, breaks = breaks)
> max.bias <- as.vector(tapply(error, groups, mean))
>
> # from cut.default()
> nb <- as.integer(breaks + 1)
> dx <- diff(rx <- range(x, na.rm = TRUE))
> breaks <- round(seq(rx[1] - dx/1000, rx[2] + dx/1000, len = nb), 2)
> mat <- cbind(breaks[1:(nb - 1)], breaks[2:nb])
>
> plot(x, error, type = "n")
> abline(h = 0, col = "grey")
> panel.smooth(x, error)
> arrows(mat[, 1], max.bias, mat[, 2], max.bias, length = 0.05,
> angle = 90, code = 3)
<snip />
Thanks also to Dimitrios and Gabor for your suggests. This suggestion
from Dimitrios is probably the one I'll use even though all three
suggestions give the same end result. I like this one because it seems
(to me) better to do the calculations than process the text labels
assigned to the list names, and because this will end up in a package to
go on CRAN I'd prefer not to add dependencies if I can avoid it -
especially if an alternative is available.
All the best,
Gav
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
* Note new Address, Telephone & Fax numbers from 6th April 2006 *
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson
ECRC & ENSIS [t] +44 (0)20 7679 0522
UCL Department of Geography [f] +44 (0)20 7679 0565
Pearson Building [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street [w] http://www.ucl.ac.uk/~ucfagls/cv/
London, UK. [w] http://www.ucl.ac.uk/~ucfagls/
WC1E 6BT.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list