>Some of us may even be able to perform comparative demonstrations!
I once tried to explain to a computer programmer friend why I thought R was the Right Thing for an open source major statistics environment, and why an open source clone of SPSS (See PSPP : http://www.gnu.org/software/pspp/) was the Wrong Thing (IMHO). I used the "99 bottles of beer" benchmark from http://99-bottles-of-beer.net . Here is a SPSS version: **************************************************************************** * File: beer.sps * Source Code: SPSS 5.0 * System/OS: HP/UNIX * Written By: Keith Chidsey ([EMAIL PROTECTED]) * * Write out lyrics to "99 Bottles of Beer on the Wall" to file <beersong>. **************************************************************************** FILE HANDLE DUMMY/NAME'BEER.SPS'/LRECL=80 FILE HANDLE BEERSONG/NAME'BEERSONG'/LRECL=80 DATA LIST FILE=DUMMY FIXED RECORDS=1/ DUMMY(A1) STRING LYRIC1,LYRIC2,SPACE(A80) LOOP BOTTLES=99 TO 1 BY -1 COMPUTE LYRIC1=CONCAT(STRING(BOTTLES,F2), ' BOTTLES OF BEER ON THE WALL, ', STRING(BOTTLES,F2), ' BOTTLES OF BEER.') COMPUTE LYRIC2=CONCAT('TAKE ONE DOWN, PASS IT AROUND, ', STRING(BOTTLES-1,F2), ' BOTTLES OF BEER ON THE WALL.') WRITE OUTFILE=BEERSONG RECORDS=3/ LYRIC1/LYRIC2/SPACE END LOOP EXECUTE FINISH And here is an S version: # 99 bottles of beer, S (R, S-Plus) version. # Demonstrates inherent vectorization of S. # Creates the correct lyrics, not as in the # original BASIC example. # Works for any n>2, default n=99. # # Giovanni Millo, Trieste (Italy) 4/10/2005 ########################### song<-function(n=99) { a<-" bottle" b<-" of beer on the wall, " c<-" of beer. " d<-"Take one down and pass it around: " # ## set "beer counter" vector counter<-c(as.character(n:1),"No more") # ## set plural s<-ifelse(counter=="1","","s") # ## build up the verses vector firsthalf<-paste(counter,a,s,b,counter,a,s,c,sep="") sechalf1.99<-paste(d,counter[-1],a,s[-1],b,sep="") sechalf100<-paste("Go to the store and buy some more: ", counter[1],a,"s",b,sep="") ## ## song is the vector of n+1 complete verses song<-paste(firsthalf,c(sechalf1.99,sechalf100),sep="") print(song) } song() Note that the S version is more correct, in that it handles the 1 beer and zero beer cases correctly, unlike the SPSS version. The S version is vectorized, whereas the SPSS version uses a loop. > >Hoping that this too is of some help, Probably not of very much help, but fun! Simon. >Ted. > >-------------------------------------------------------------------- >E-Mail: (Ted Harding) <[EMAIL PROTECTED]> >Fax-to-email: +44 (0)870 094 0861 >Date: 09-Nov-06 Time: 23:01:24 >------------------------------ XFMail ------------------------------ > >______________________________________________ >[email protected] mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. -- Simon Blomberg, B.Sc.(Hons.), Ph.D, M.App.Stat. Centre for Resource and Environmental Studies The Australian National University Canberra ACT 0200 Australia T: +61 2 6125 7800 F: +61 2 6125 0757 CRICOS Provider # 00120C [[alternative HTML version deleted]] ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
