[Rd] sprintf crash (PR#2327)

tlumley@u.washington.edu tlumley@u.washington.edu
Tue, 26 Nov 2002 17:46:41 +0100 (MET)


>2) Under MacOS 10.2.2. Given the following dataset:
>
> > summary(missing.data)
>    Hosp..No.                   Category      Offset        Side
>  r060093:  4   F Post op 0.5 year  :62   Min.   :-5.8333   L: 63
>  r023250:  3   E Pre op 0.5 year   :54   1st Qu.:-0.4167   R:141
>  r026316:  3   H Post op 1.5 years :44   Median : 7.7083
>  r032583:  3   G Post op 1 year    :41   Mean   :14.2623
>  r036827:  3   I Post op 2 years   : 3   3rd Qu.:27.0833
>  r055869:  3   A Pre op > 2.5 years: 0   Max.   :47.6667
>  (Other):185   (Other)             : 0
 <snip>
>The line:
>
>sprintf("%s\t%1.0f", missing.data$Hosp..No., missing.data$V1)
>
>always crashes R.

 Yes, that's because  missing.data$Hosp..No. isn't a string, it's a
factor.  In R 1.6.0 this gives an error rather than a crash.

You probably want

  sprintf("%s\t%1.0f", as.character(missing.data$Hosp..No.),
	missing.data$V1)



	-thomas