[comp.sources.bugs] Patch 1 to Reldb - Relational database and graphing tools

gunnar@hafro.is (Gunnar Stefansson) (09/26/89)

This is patch 1 to Reldb, the simple collection of programs for
relational database manipulation and plotting, which was posted in
comp.sources.unix a short time ago.  Due to the long time lag in
comp.sources.unix, we have had time to do a number of changes to the
programs. 

What follows are patches/mods to the conversion routines and
documentation.  These include a couple of renamings, solving a couple of
problems which occurred during the original transmission and setting up
a patchlevel.h file.

In the following two postings (patches 2 and 3) we will send out various
other modifications which have improved the plotting stuff by quite a bit.

To insert these patches:

	cd to wherever you are keeping the sources
	      (an ls should give you the directories doc, convert.src
	      and others)
	run this file through 'patch -p'  **you MUST use the option**


*** convert.src/S/pretoS	Thu Sep 21 19:57:34 1989
--- convert.src/S/pretoS	Mon Sep 25 21:49:22 1989
***************
*** 1,25 ****
- #!/bin/sh
- #
- # Convert Prelude file to S files
- #
- # Ideally, the first column in the Prelude file should be a labelling column,
- # e.g. year.
- 
- FILE=$1
- cat $FILE > /tmp/tmp$$
- tail +3 < /tmp/tmp$$ | grep -v '\-999	' > $FILE.s
-     ( echo '-f	' ; awk 'NR==1{for(i=1;i<=NF;i++)print $i,"REAL",i}' < /tmp/tmp$$) > $FILE.s.des
-     Splus extract $FILE.s
- 
- sed -n  '3,$s/^\([^	]*\).*$/"\1"/p' < /tmp/tmp$$ > rownames.txt
- head -1 /tmp/tmp$$ |
- 	tr '	' '\012' | sed 's/\(.*\)/"\1"/' > varnames.txt
- NCOL=`wc -l < varnames.txt`
- rm /tmp/tmp$$
- echo 'Now use restore("'$FILE'.s.ext") within Splus, to read the data 
- 	or use x<-matrix(read("'$FILE'.s"),ncol='$NCOL',byrow=TRUE)
- 	to read the data as a matrix
- 	and colnames<-read("varnames.txt") to get the column labels
- 	for the matrix.
- 	If the first column contained labels, you can use
- 	rownames<-read("rownames.txt") to get the row labels.'
--- 0 ----
No differences encountered
*** /dev/null	Tue Sep 26 10:45:31 1989
--- convert.src/S/reldbtoS	Tue Sep 26 09:16:18 1989
***************
*** 0 ****
--- 1,39 ----
+ #!/bin/sh
+ #
+ # Convert Reldb file to S files
+ #
+ # Ideally, the first column in the Reldb file should be a labelling column,
+ # e.g. year.
+ #
+ # S is AT&T's statistical package. This script assumes you are using
+ # the Splus version, but should be easily modified for generic S.
+ #
+ # Most people will want to use S on a workstation running a windowing
+ # system. For such use, it's nice to have this script print out
+ # directions that can then be pasted into S, using the mouse.
+ 
+ if [ ! -f $1 ]
+ then
+ 	echo "Usage: 'reldbtoS filenam'"
+ 	echo "Filename must be specified"
+ 	exit
+ fi
+ 
+ FILE=$1
+ cat $FILE > /tmp/tmp$$
+ tail +3 < /tmp/tmp$$ | grep -v '\-999	' > $FILE.s
+     ( echo '-f	' ; awk 'NR==1{for(i=1;i<=NF;i++)print $i,"REAL",i}' < /tmp/tmp$$) > $FILE.s.des
+     Splus extract $FILE.s
+ 
+ sed -n  '3,$s/^\([^	]*\).*$/"\1"/p' < /tmp/tmp$$ > rownames.txt
+ head -1 /tmp/tmp$$ |
+ 	tr '	' '\012' | sed 's/\(.*\)/"\1"/' > varnames.txt
+ NCOL=`wc -l < varnames.txt`
+ rm /tmp/tmp$$
+ echo 'Now use restore("'$FILE'.s.ext") within Splus, to read the data 
+ 	or use x<-matrix(read("'$FILE'.s"),ncol='$NCOL',byrow=TRUE)
+ 	to read the data as a matrix
+ 	and colnames<-read("varnames.txt") to get the column labels
+ 	for the matrix.
+ 	If the first column contained labels, you can use
+ 	rownames<-read("rownames.txt") to get the row labels.'
*** convert.src/Glim/pretoglim	Thu Sep 21 19:57:33 1989
--- convert.src/Glim/pretoglim	Tue Sep 26 09:07:11 1989
***************
*** 1,24 ****
- :
- # pretoglim.sh -- convert prelude to glim file
- #
- read header
- read dummy
- awk '{	for(i=1;i<NF;i++){
- 		if($(i)==int($(i)))
- 			printf("%d ",$(i));
- 		else if($(i)>1)
- 			printf("%.6f ",$(i));
- 		else
- 			printf("%f ",$(i));
- 		}
- 	printf("%.4f\n",$(NF))
-      }' > glimdat.junk
- units=`wc -l < glimdat.junk `
- echo "\$units $units 
- \$echo
- \$data $header
- \$read" | sed 's/	/ \
- /g' > glimcmds.junk
- 
- echo 'Data in glimdat.junk, commands in glimcmds.junk'
- echo "Use 'cat glimcmds.junk glimdat.junk command-file | glim' to run "
--- 0 ----
*** /dev/null	Tue Sep 26 10:45:31 1989
--- convert.src/Glim/README	Tue Sep 26 09:28:47 1989
***************
*** 0 ****
--- 1,5 ----
+ Here is a shell script, reldbtoglim, which converts a reldb file to 
+ the stuff needed to read the data into GLIM.
+ 
+ GLIM is the Generalized Linear Interactive Modelling package
+ distributed by NAG (Numerical Algorithms Group, England).
*** /dev/null	Tue Sep 26 10:45:31 1989
--- convert.src/Glim/reldbtoglim	Mon Sep 25 21:22:36 1989
***************
*** 0 ****
--- 1,25 ----
+ :
+ # reldbtoglim.sh -- convert prelude to glim file
+ #
+ read header
+ read dummy
+ awk '{	for(i=1;i<NF;i++){
+ 		if($(i)==int($(i)))
+ 			printf("%d ",$(i));
+ 		else if($(i)>1)
+ 			printf("%.6f ",$(i));
+ 		else
+ 			printf("%f ",$(i));
+ 		}
+ 	printf("%.4f\n",$(NF))
+      }' > glimdat.junk
+ units=`wc -l < glimdat.junk `
+ echo "\$units $units 
+ \$echo
+ \$data $header
+ \$read" | sed 's/	/ \
+ /g' > glimcmds.junk
+ 
+ echo 'Data in glimdat.junk, commands in glimcmds.junk'
+ echo "Use 'cat glimcmds.junk glimdat.junk command-file | glim' to run "
+ echo '(Where "command-file" is your own file of glim-commands)'
No differences encountered
No differences encountered
No differences encountered
*** convert.src/Bmdp/README	Thu Sep 21 19:57:36 1989
--- convert.src/Bmdp/README	Tue Sep 26 09:31:10 1989
***************
*** 1,4 ****
  README
! pretobmdp 	Converts reldb to BMDP
! 	Sample input file:
  
--- 1,4 ----
  README
! reldbtobmdp 	Converts reldb to BMDP
! Sample input file:
  
***************
*** 6,8 ****
  
! 	Sample command:
  
--- 6,8 ----
  
! Sample command:
  
***************
*** 10,12 ****
  
! 	Output files:
  
--- 10,19 ----
  
! 	The required argument is the file name.
! 	Other (optional) arguments are names of
! 	columns which are to be used as factors.
! 	This feature is very useful if you have
! 	a factor with many levels -- Bmdp is
! 	terrible in its handling of factors.
! 
! Output files:
  
No differences encountered
No differences encountered
*** convert.src/Bmdp/bmdp.test	Thu Sep 21 19:57:38 1989
--- convert.src/Bmdp/bmdp.test	Tue Sep 26 09:08:07 1989
***************
*** 1,133 ****
- 
- else
-   echo "will not over write ./convert.src/Bmdp/bmdp.test"
- fi
- if `test ! -s ./convert.src/Bmdp/pretobmdp.sh`
- then
- echo "writting ./convert.src/Bmdp/pretobmdp.sh"
- cat > ./convert.src/Bmdp/pretobmdp.sh << '\Rogue\Monster\'
- #!/bin/sh
- #
- # pretobmdp -- convert reldb to bmdp format
- #
- # Usage: pretobmdp input-file [factors]
- #
- # Converts the input file to BMDP format and sets up a BMDP script
- # to read that file. The runs the script, generates a BMDP data set
- # and suggests a next step.
- 
- if [ ! -f "$1" ]
- then
- 	echo "Usage: pretobmdp input-file [factors]"
- 	echo "(Input file must be specified)"
- 	exit 1
- fi
- INFILE=$1
- 
- # First set up the correct missing-value notation.
- sed '
- s/^	/*	/
- s/	$/	*/
- s/	-1	/	*	/g
- s/	-1	/	*	/g
- s/	-1	/	*	/g
- s/		/	*	/g
- s/		/	*	/g
- s/		/	*	/g
- ' < $1  > tmp$$.pre
- # First read Reldb header lines
- read names < $1				# column names
- t=`echo $names | wc -w`			# compute number of variables
- bmnames=`echo "$names"|sed 's/	/, /g' | tr ' ' '\012'` # make bmdp name list
- (echo '/PROBLEM   TITLE IS '\''Heiti verkefnis'\''.
- /PRINT PAGE=66.
- 	LINE=80.
- /INPUT VARIABLES ARE '$t'.
-            FORMAT IS FREE.
- /VARIABLE NAMES ARE ' "$bmnames". '
- /SAVE FILE IS '\''bmdp.test'\'.'
-      CODE IS TEST_DATA.
-      NEW.
- /END'
- sed '
- 1,2d
- s/	/ /g') < tmp$$.pre  > junkfile
- 
- # The file 'junkfile' now contains a bmdp-style file, ready e.g. for
- # the program 1v. Running this program will give a bmdp data file,
- # called bmdp.test
- 
- echo "junkfile contains a simple bmdp program + data
- WARNING : <tab><tab> was assumed to mean a missing value. 
- ALSO <tab>-1<tab> !!! These have been coded to bmdp missing values.
- The following is the output from the command '1d < junkfile'"
- 
- 1d < junkfile
- 
- echo "The '1d'-run generated bmdp.test, which contains the data in bmdp format"
- 
- # Now to give a sample program to read bmdp.test
- 
- echo '/PROBLEM   TITLE IS '\''Heiti verkefnis'\''.
- /PRINT PAGE=66.
- 	LINE=80.
- /INPUT  FILE IS '\''bmdp.test'\'.'
- 	CODE IS TEST_DATA.' > 2d.inp
- 
- shift 
- 
- # Remaining arguments are factors
- #
- # When they exist, we will set up a histogram- and 
- # multiple regression program (7d.inp and 2v.inp).
- # These are very similar, but not quite the same.
- 
- if [ $# -ge 1 ]
- then
- 	echo -n "Processing your factors:"
- 	cp 2d.inp 7d.inp
- 	echo '/GROUP'  >> 7d.inp
- 	for i			# Generate a code-stmnt
- 	do
- 		echo -n "$i..."
- 		echo " CODES($i) ARE " >> 7d.inp
- 		project $i < tmp$$.pre | 
- 			tail +3 |
- 			sort -u | sed -e 's/$/,/'  \
- 					-e '$s/,$/./' \
- 					-e '/\*/d' >> 7d.inp
- 	done  
- 	echo -n "Finishing up..."
- 	var=`sed -e '1{s/\([^	]\)	.*/\1./
- 		  q
- 		 }' < tmp$$.pre`	# Use 1st var as dependent
- 	echo "VARIABLE=$var" >> 7d.inp
- 	cp 7d.inp 2v.inp		# This is ends the similarity 7d=2v 
- 	echo '/HISTOGRAM 
-               GROUPING=' >> 7d.inp
- 	echo "/DESIGN DEPENDENT IS $var.
-               GROUPING ARE " >> 2v.inp
- 	x=`echo $* | sed -e 's/  */,/g' -e 's/$/./'`
- 	echo $x >> 7d.inp
- 	echo $x >> 2v.inp
- 
- 	echo '/END' >> 7d.inp
- fi 
- echo '/END' >> 2d.inp
- 
- echo "Done"
- echo "bmdp.prog contains a bmdp program to read bmdp.test and to
- generate simple statistics. 
- 
- Your next step(s) should be :
- 
- 	2d < 2d.inp"
- if [ -f 7d.inp ]
- then
- 	echo ' 	2v < 2v.inp'
- 	echo ' 	2d < 2d.inp'
- 	echo ' 	7d < 7d.inp'
- fi
- echo "and then use the files" *.inp "for future development."
- 
- rm -f tmp$$.pre
--- 0 ----
*** /dev/null	Tue Sep 26 10:45:31 1989
--- convert.src/Bmdp/reldbtobmdp	Mon Sep 25 21:21:27 1989
***************
*** 0 ****
--- 1,125 ----
+ #!/bin/sh
+ #
+ # reldbtobmdp -- convert reldb to bmdp format
+ #
+ # Usage: reldbtobmdp input-file [factors]
+ #
+ # Converts the input file to BMDP format and sets up a BMDP script
+ # to read that file. The runs the script, generates a BMDP data set
+ # and suggests a next step.
+ 
+ if [ ! -f "$1" ]
+ then
+ 	echo "Usage: reldbtobmdp input-file [factors]"
+ 	echo "(Input file must be specified)"
+ 	exit 1
+ fi
+ INFILE=$1
+ 
+ # First set up the correct missing-value notation.
+ sed '
+ s/^	/*	/
+ s/	$/	*/
+ s/	-1	/	*	/g
+ s/	-1	/	*	/g
+ s/	-1	/	*	/g
+ s/		/	*	/g
+ s/		/	*	/g
+ s/		/	*	/g
+ ' < $1  > tmp$$.pre
+ # First read Reldb header lines
+ read names < $1				# column names
+ t=`echo $names | wc -w`			# compute number of variables
+ bmnames=`echo "$names"|sed 's/	/, /g' | tr ' ' '\012'` # make bmdp name list
+ (echo '/PROBLEM   TITLE IS '\''Stick in your job name here'\''.
+ /PRINT PAGE=66.
+ 	LINE=80.
+ /INPUT VARIABLES ARE '$t'.
+            FORMAT IS FREE.
+ /VARIABLE NAMES ARE ' "$bmnames". '
+ /SAVE FILE IS '\''bmdp.test'\'.'
+      CODE IS TEST_DATA.
+      NEW.
+ /END'
+ sed '
+ 1,2d
+ s/	/ /g') < tmp$$.pre  > junkfile
+ 
+ # The file 'junkfile' now contains a bmdp-style file, ready e.g. for
+ # the program 1v. Running this program will give a bmdp data file,
+ # called bmdp.test
+ 
+ echo "junkfile contains a simple bmdp program + data
+ WARNING : <tab><tab> was assumed to mean a missing value. 
+ ALSO <tab>-1<tab> !!! These have been coded to bmdp missing values.
+ The following is the output from the command '1d < junkfile'"
+ 
+ 1d < junkfile
+ 
+ echo "The '1d'-run generated bmdp.test, which contains the data in bmdp format"
+ 
+ # Now to give a sample program to read bmdp.test
+ 
+ echo '/PROBLEM   TITLE IS '\''Stick in your job name here'\''.
+ /PRINT PAGE=66.
+ 	LINE=80.
+ /INPUT  FILE IS '\''bmdp.test'\'.'
+ 	CODE IS TEST_DATA.' > 2d.inp
+ 
+ shift 
+ 
+ # Remaining arguments are factors
+ #
+ # When they exist, we will set up a histogram- and 
+ # multiple regression program (7d.inp and 2v.inp).
+ # These are very similar, but not quite the same.
+ 
+ if [ $# -ge 1 ]
+ then
+ 	echo -n "Processing your factors:"
+ 	cp 2d.inp 7d.inp
+ 	echo '/GROUP'  >> 7d.inp
+ 	for i			# Generate a code-stmnt
+ 	do
+ 		echo -n "$i..."
+ 		echo " CODES($i) ARE " >> 7d.inp
+ 		project $i < tmp$$.pre | 
+ 			tail +3 |
+ 			sort -u | sed -e 's/$/,/'  \
+ 					-e '$s/,$/./' \
+ 					-e '/\*/d' >> 7d.inp
+ 	done  
+ 	echo -n "Finishing up..."
+ 	var=`sed -e '1{s/\([^	]\)	.*/\1./
+ 		  q
+ 		 }' < tmp$$.pre`	# Use 1st var as dependent
+ 	echo "VARIABLE=$var" >> 7d.inp
+ 	cp 7d.inp 2v.inp		# This is ends the similarity 7d=2v 
+ 	echo '/HISTOGRAM 
+               GROUPING=' >> 7d.inp
+ 	echo "/DESIGN DEPENDENT IS $var.
+               GROUPING ARE " >> 2v.inp
+ 	x=`echo $* | sed -e 's/  */,/g' -e 's/$/./'`
+ 	echo $x >> 7d.inp
+ 	echo $x >> 2v.inp
+ 
+ 	echo '/END' >> 7d.inp
+ fi 
+ echo '/END' >> 2d.inp
+ 
+ echo "Done"
+ echo "bmdp.prog contains a bmdp program to read bmdp.test and to
+ generate simple statistics. 
+ 
+ Your next step(s) should be :
+ 
+ 	2d < 2d.inp"
+ if [ -f 7d.inp ]
+ then
+ 	echo ' 	2v < 2v.inp'
+ 	echo ' 	2d < 2d.inp'
+ 	echo ' 	7d < 7d.inp'
+ fi
+ echo "and then use the files" *.inp "for future development."
+ 
+ rm -f tmp$$.pre
No differences encountered
*** /dev/null	Tue Sep 26 10:45:31 1989
--- patchlevel.h	Tue Sep 26 09:10:33 1989
***************
*** 0 ****
--- 1 ----
+ #define PATCHLEVEL 1
-- 
-----------------------------------------------------------------------------
Gunnar Stefansson                       Uucp: {mcvax,enea}!hafro!gunnar 
Marine Research Institute		Internet: gunnar@hafro.is
P.O. Box 1390,Reykjavik    		Tel: +354 1 20240 Fax: +354 1 623790