readBin() can read beyond end of raw vector
Thanks for the report. BTW, this is not new in 2.5.0 alpha AFAICS. It needs a tiny change in the C function readRaw: fixed in SVN now.
On Sat, 7 Apr 2007, Henrik Bengtsson wrote:
FYI, in R v2.5.0 alpha, readBin() can be used to read beyond end of raw vector:
bfr <- as.raw(1:10) readBin(con=bfr, what="raw", n=20)
[1] 01 02 03 04 05 06 07 08 09 0a
readBin(con=bfr, what="integer", n=20)
[1] 67305985 134678021
readBin(con=bfr, what="integer", size=4, n=20)
[1] 67305985 134678021
readBin(con=bfr, what="integer", size=2, n=20)
[1] 513 1027 1541 2055 2569 29537 29541 0 9 16384 [11] 9376 453 -18208 505 -18328 505 9 0 0 0
readBin(con=bfr, what="integer", size=1, n=20)
[1] 1 2 3 4 5 6 7 8 9 10 97 115 101 115 0 0 9 0 0 [20] 64
sessionInfo()
R version 2.5.0 alpha (2007-04-04 r41043) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MON ETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" [7] "base" /Henrik
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595