D.Wischik at cs.ucl.ac.uk
2007-Apr-17 14:12 UTC
[Rd] format() applied to an NA character string (PR#9616)
I get strange results when I try to format() an NA character string.> x <- 'sometext' > x[1] <- NA > format(NA, width=32) # displays sensibly, right-justified > format(x,width=32) # displays sensibly, left-justified > format(x,width=33) # displays "" > format(x,width=36) # R exits abnormally with code 5> versionplatform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 4.1 year 2006 month 12 day 18 svn rev 40228 language R version.string R version 2.4.1 (2006-12-18) I'm running Windows XP. Damon.
Peter Dalgaard
2007-Apr-18 09:41 UTC
[Rd] format() applied to an NA character string (PR#9616)
D.Wischik at cs.ucl.ac.uk wrote:> I get strange results when I try to format() an NA character string. > > >> x <- 'sometext' >> x[1] <- NA >> format(NA, width=32) # displays sensibly, right-justified >> format(x,width=32) # displays sensibly, left-justified >> format(x,width=33) # displays "" >> format(x,width=36) # R exits abnormally with code 5 >> > >This happens on Linux too, given slightly larger widths: R version 2.5.0 RC (2007-04-17 r41210) ....> x <- as.character(NA) > format(x,width=64)Program received signal SIGSEGV, Segmentation fault. Rstrlen (s=0x20000009, quote=0) at ../../../R/src/main/printutils.c:374 374 return Rstrwid(CHAR(s), LENGTH(s), quote);>> version >> > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 2 > minor 4.1 > year 2006 > month 12 > day 18 > svn rev 40228 > language R > version.string R version 2.4.1 (2006-12-18) > > I'm running Windows XP. > > Damon. > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >-- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
ripley at stats.ox.ac.uk
2007-Apr-18 15:34 UTC
[Rd] format() applied to an NA character string (PR#9616)
On Wed, 18 Apr 2007, Peter Dalgaard wrote:> D.Wischik at cs.ucl.ac.uk wrote: >> I get strange results when I try to format() an NA character string. >> >> >>> x <- 'sometext' >>> x[1] <- NA >>> format(NA, width=32) # displays sensibly, right-justified >>> format(x,width=32) # displays sensibly, left-justified >>> format(x,width=33) # displays "" >>> format(x,width=36) # R exits abnormally with code 5 >>> >> >> > This happens on Linux too, given slightly larger widths:It happened for me on Linux in R 2.4.1 at width=32, but those examples are fine on both Linux and Windows in pre-2.5.0. It was (of course) a buffer overflow, fixed now for 2.5.0. Valgrind got to the correct spot (in paste.c).> > R version 2.5.0 RC (2007-04-17 r41210) > .... >> x <- as.character(NA) >> format(x,width=64) > > Program received signal SIGSEGV, Segmentation fault. > Rstrlen (s=0x20000009, quote=0) at ../../../R/src/main/printutils.c:374 > 374 return Rstrwid(CHAR(s), LENGTH(s), quote); > > > >>> version >>> >> platform i386-pc-mingw32 >> arch i386 >> os mingw32 >> system i386, mingw32 >> status >> major 2 >> minor 4.1 >> year 2006 >> month 12 >> day 18 >> svn rev 40228 >> language R >> version.string R version 2.4.1 (2006-12-18) >> >> I'm running Windows XP. >> >> Damon. >> >> ______________________________________________ >> 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