home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume20 / reldb / part03 < prev    next >
Encoding:
Internet Message Format  |  1989-09-17  |  45.9 KB

  1. Subject:  v20i006:  Relational database and graphing tools, Part03/03
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: hafro.is!gunnar (Gunnar Stefansson)
  7. Posting-number: Volume 20, Issue 6
  8. Archive-name: reldb/part03
  9.  
  10. #!/bin/sh
  11. # to extract, remove the header and type "sh filename"
  12. if `test ! -s ./README`
  13. then
  14. echo "writting ./README"
  15. cat > ./README << '\Rogue\Monster\'
  16. Here is a neat little collection of programs to do all sorts of
  17. handy things.
  18.  
  19. Directories:
  20.     reldb.src    Programs for relational database operations
  21.     plot.src    Plot(1) filter (for X11).
  22.     scat.src    Program for drawing simple plots (SCATtergram)
  23.     doc        Documentation
  24.     testdb        Sample programs for testing the reldb collection.
  25.     testgr        Sample programs for testing the scat options.
  26.  
  27. Cd to each directory and examine the Makefiles and README files.
  28. Note that some makefiles may do automatic installation.
  29. \Rogue\Monster\
  30. else
  31.   echo "will not over write ./README"
  32. fi
  33. if `test ! -d ./bin`
  34. then
  35.   mkdir ./bin
  36.   echo "mkdir ./bin"
  37. fi
  38. if `test ! -s ./bin/README`
  39. then
  40. echo "writting ./bin/README"
  41. cat > ./bin/README << '\Rogue\Monster\'
  42. This is the default location for binary files. The directory can safely
  43. be removed, but is included in the distribution simply so that the binaries
  44. have someplace to go in case 'make' is used without appropriate local
  45. modifications of the Makefiles.
  46. \Rogue\Monster\
  47. else
  48.   echo "will not over write ./bin/README"
  49. fi
  50. if `test ! -d ./convert.src`
  51. then
  52.   mkdir ./convert.src
  53.   echo "mkdir ./convert.src"
  54. fi
  55. if `test ! -d ./convert.src/Glim`
  56. then
  57.   mkdir ./convert.src/Glim
  58.   echo "mkdir ./convert.src/Glim"
  59. fi
  60. if `test ! -s ./convert.src/Glim/pretoglim`
  61. then
  62. echo "writting ./convert.src/Glim/pretoglim"
  63. cat > ./convert.src/Glim/pretoglim << '\Rogue\Monster\'
  64. :
  65. # pretoglim.sh -- convert prelude to glim file
  66. #
  67. read header
  68. read dummy
  69. awk '{    for(i=1;i<NF;i++){
  70.         if($(i)==int($(i)))
  71.             printf("%d ",$(i));
  72.         else if($(i)>1)
  73.             printf("%.6f ",$(i));
  74.         else
  75.             printf("%f ",$(i));
  76.         }
  77.     printf("%.4f\n",$(NF))
  78.      }' > glimdat.junk
  79. units=`wc -l < glimdat.junk `
  80. echo "\$units $units 
  81. \$echo
  82. \$data $header
  83. \$read" | sed 's/    / \
  84. /g' > glimcmds.junk
  85.  
  86. echo 'Data in glimdat.junk, commands in glimcmds.junk'
  87. echo "Use 'cat glimcmds.junk glimdat.junk command-file | glim' to run "
  88. \Rogue\Monster\
  89. else
  90.   echo "will not over write ./convert.src/Glim/pretoglim"
  91. fi
  92. if `test ! -s ./convert.src/README`
  93. then
  94. echo "writting ./convert.src/README"
  95. cat > ./convert.src/README << '\Rogue\Monster\'
  96. Files for converting from reldb to various other formats.
  97.  
  98. The directory names say it all.
  99.  
  100. These programs are merely hints - they are currently run on
  101. a mix of machines (hp and sun), but not all programs work on
  102. all machines. 
  103.  
  104. (We can't test all combinations, since we don't have all packages 
  105. on all machines).
  106.  
  107. \Rogue\Monster\
  108. else
  109.   echo "will not over write ./convert.src/README"
  110. fi
  111. if `test ! -d ./convert.src/S`
  112. then
  113.   mkdir ./convert.src/S
  114.   echo "mkdir ./convert.src/S"
  115. fi
  116. if `test ! -s ./convert.src/S/pretoS`
  117. then
  118. echo "writting ./convert.src/S/pretoS"
  119. cat > ./convert.src/S/pretoS << '\Rogue\Monster\'
  120. #!/bin/sh
  121. #
  122. # Convert Prelude file to S files
  123. #
  124. # Ideally, the first column in the Prelude file should be a labelling column,
  125. # e.g. year.
  126.  
  127. FILE=$1
  128. cat $FILE > /tmp/tmp$$
  129. tail +3 < /tmp/tmp$$ | grep -v '\-999    ' > $FILE.s
  130.     ( echo '-f    ' ; awk 'NR==1{for(i=1;i<=NF;i++)print $i,"REAL",i}' < /tmp/tmp$$) > $FILE.s.des
  131.     Splus extract $FILE.s
  132.  
  133. sed -n  '3,$s/^\([^    ]*\).*$/"\1"/p' < /tmp/tmp$$ > rownames.txt
  134. head -1 /tmp/tmp$$ |
  135.     tr '    ' '\012' | sed 's/\(.*\)/"\1"/' > varnames.txt
  136. NCOL=`wc -l < varnames.txt`
  137. rm /tmp/tmp$$
  138. echo 'Now use restore("'$FILE'.s.ext") within Splus, to read the data 
  139.     or use x<-matrix(read("'$FILE'.s"),ncol='$NCOL',byrow=TRUE)
  140.     to read the data as a matrix
  141.     and colnames<-read("varnames.txt") to get the column labels
  142.     for the matrix.
  143.     If the first column contained labels, you can use
  144.     rownames<-read("rownames.txt") to get the row labels.'
  145. \Rogue\Monster\
  146. else
  147.   echo "will not over write ./convert.src/S/pretoS"
  148. fi
  149. if `test ! -d ./convert.src/Bmdp`
  150. then
  151.   mkdir ./convert.src/Bmdp
  152.   echo "mkdir ./convert.src/Bmdp"
  153. fi
  154. if `test ! -s ./convert.src/Bmdp/2d.inp`
  155. then
  156. echo "writting ./convert.src/Bmdp/2d.inp"
  157. cat > ./convert.src/Bmdp/2d.inp << '\Rogue\Monster\'
  158. /PROBLEM   TITLE IS 'Heiti verkefnis'.
  159. /PRINT PAGE=66.
  160.     LINE=80.
  161. /INPUT  FILE IS 'bmdp.test'.
  162.     CODE IS TEST_DATA.
  163. /END
  164. \Rogue\Monster\
  165. else
  166.   echo "will not over write ./convert.src/Bmdp/2d.inp"
  167. fi
  168. if `test ! -s ./convert.src/Bmdp/7d.inp`
  169. then
  170. echo "writting ./convert.src/Bmdp/7d.inp"
  171. cat > ./convert.src/Bmdp/7d.inp << '\Rogue\Monster\'
  172. /PROBLEM   TITLE IS 'Heiti verkefnis'.
  173. /PRINT PAGE=66.
  174.     LINE=80.
  175. /INPUT  FILE IS 'bmdp.test'.
  176.     CODE IS TEST_DATA.
  177. /GROUP
  178.  CODES(y) ARE 
  179. 1,
  180. 3,
  181. 4,
  182. 5.
  183.  CODES(z) ARE 
  184. 2,
  185. 3,
  186. 4,
  187. 5,
  188. 6.
  189. /HISTOGRAM 
  190.               GROUPING=
  191. z.
  192. VARIABLE=x.
  193. /END
  194. \Rogue\Monster\
  195. else
  196.   echo "will not over write ./convert.src/Bmdp/7d.inp"
  197. fi
  198. if `test ! -s ./convert.src/Bmdp/Makefile`
  199. then
  200. echo "writting ./convert.src/Bmdp/Makefile"
  201. cat > ./convert.src/Bmdp/Makefile << '\Rogue\Monster\'
  202. #
  203. # BINDIR is where the binaries and scripts go. Note that a simple 'make'
  204. # will also install. You'll want to define BINDIR as ../bin untill
  205. # you know things work.
  206. #
  207. BINDIR=/usr/local/bin
  208. #
  209. # Use -DBSD for all BSD-systems
  210. #     -DSYSV for sysv-style systems
  211. #
  212. CFLAGS= -DDEBUG=0 -DBSD
  213. BINARIES= $(BINDIR)/pretobmdp 
  214. $(BINDIR)/pretobmdp : pretobmdp.sh
  215.     cp  pretobmdp.sh $(BINDIR)/pretobmdp
  216.     chmod +x $(BINDIR)/pretobmdp
  217. \Rogue\Monster\
  218. else
  219.   echo "will not over write ./convert.src/Bmdp/Makefile"
  220. fi
  221. if `test ! -s ./convert.src/Bmdp/README`
  222. then
  223. echo "writting ./convert.src/Bmdp/README"
  224. cat > ./convert.src/Bmdp/README << '\Rogue\Monster\'
  225. README
  226. pretobmdp     Converts reldb to BMDP
  227.     Sample input file:
  228.  
  229.     bmdp.reldb
  230.  
  231.     Sample command:
  232.  
  233.     pretobmdp bmdp.reldb y z 
  234.  
  235.     Output files:
  236.  
  237.     bmdp.prog
  238.     bmdp.test
  239.     junkfile
  240. \Rogue\Monster\
  241. else
  242.   echo "will not over write ./convert.src/Bmdp/README"
  243. fi
  244. if `test ! -s ./convert.src/Bmdp/bmdp.prog`
  245. then
  246. echo "writting ./convert.src/Bmdp/bmdp.prog"
  247. cat > ./convert.src/Bmdp/bmdp.prog << '\Rogue\Monster\'
  248. /PROBLEM   TITLE IS 'Heiti verkefnis'.
  249. /PRINT PAGE=66.
  250.     LINE=80.
  251. /INPUT  FILE IS 'bmdp.test'.
  252.     CODE IS TEST_DATA.
  253. /GROUP
  254.  CODES(y) ARE 
  255. 1,
  256. 3,
  257. 4,
  258. 5.
  259.  CODES(z) ARE 
  260. 2,
  261. 3,
  262. 4,
  263. 5,
  264. 6.
  265. /END
  266. \Rogue\Monster\
  267. else
  268.   echo "will not over write ./convert.src/Bmdp/bmdp.prog"
  269. fi
  270. if `test ! -s ./convert.src/Bmdp/bmdp.reldb`
  271. then
  272. echo "writting ./convert.src/Bmdp/bmdp.reldb"
  273. cat > ./convert.src/Bmdp/bmdp.reldb << '\Rogue\Monster\'
  274. x    y    z    v
  275. -    -    -    -
  276. 0    1    2    3
  277. 1        3    4
  278. 2    3    4    5
  279. 3    4    5    6
  280. 4    5    6    7
  281. \Rogue\Monster\
  282. else
  283.   echo "will not over write ./convert.src/Bmdp/bmdp.reldb"
  284. fi
  285. if `test ! -s ./convert.src/Bmdp/bmdp.test`
  286. then
  287. echo "writting ./convert.src/Bmdp/bmdp.test"
  288. cat > ./convert.src/Bmdp/bmdp.test << '\Rogue\Monster\'
  289.  
  290. else
  291.   echo "will not over write ./convert.src/Bmdp/bmdp.test"
  292. fi
  293. if `test ! -s ./convert.src/Bmdp/pretobmdp.sh`
  294. then
  295. echo "writting ./convert.src/Bmdp/pretobmdp.sh"
  296. cat > ./convert.src/Bmdp/pretobmdp.sh << '\Rogue\Monster\'
  297. #!/bin/sh
  298. #
  299. # pretobmdp -- convert reldb to bmdp format
  300. #
  301. # Usage: pretobmdp input-file [factors]
  302. #
  303. # Converts the input file to BMDP format and sets up a BMDP script
  304. # to read that file. The runs the script, generates a BMDP data set
  305. # and suggests a next step.
  306.  
  307. if [ ! -f "$1" ]
  308. then
  309.     echo "Usage: pretobmdp input-file [factors]"
  310.     echo "(Input file must be specified)"
  311.     exit 1
  312. fi
  313. INFILE=$1
  314.  
  315. # First set up the correct missing-value notation.
  316. sed '
  317. s/^    /*    /
  318. s/    $/    */
  319. s/    -1    /    *    /g
  320. s/    -1    /    *    /g
  321. s/    -1    /    *    /g
  322. s/        /    *    /g
  323. s/        /    *    /g
  324. s/        /    *    /g
  325. ' < $1  > tmp$$.pre
  326. # First read Reldb header lines
  327. read names < $1                # column names
  328. t=`echo $names | wc -w`            # compute number of variables
  329. bmnames=`echo "$names"|sed 's/    /, /g' | tr ' ' '\012'` # make bmdp name list
  330. (echo '/PROBLEM   TITLE IS '\''Heiti verkefnis'\''.
  331. /PRINT PAGE=66.
  332.     LINE=80.
  333. /INPUT VARIABLES ARE '$t'.
  334.            FORMAT IS FREE.
  335. /VARIABLE NAMES ARE ' "$bmnames". '
  336. /SAVE FILE IS '\''bmdp.test'\'.'
  337.      CODE IS TEST_DATA.
  338.      NEW.
  339. /END'
  340. sed '
  341. 1,2d
  342. s/    / /g') < tmp$$.pre  > junkfile
  343.  
  344. # The file 'junkfile' now contains a bmdp-style file, ready e.g. for
  345. # the program 1v. Running this program will give a bmdp data file,
  346. # called bmdp.test
  347.  
  348. echo "junkfile contains a simple bmdp program + data
  349. WARNING : <tab><tab> was assumed to mean a missing value. 
  350. ALSO <tab>-1<tab> !!! These have been coded to bmdp missing values.
  351. The following is the output from the command '1d < junkfile'"
  352.  
  353. 1d < junkfile
  354.  
  355. echo "The '1d'-run generated bmdp.test, which contains the data in bmdp format"
  356.  
  357. # Now to give a sample program to read bmdp.test
  358.  
  359. echo '/PROBLEM   TITLE IS '\''Heiti verkefnis'\''.
  360. /PRINT PAGE=66.
  361.     LINE=80.
  362. /INPUT  FILE IS '\''bmdp.test'\'.'
  363.     CODE IS TEST_DATA.' > 2d.inp
  364.  
  365. shift 
  366.  
  367. # Remaining arguments are factors
  368. #
  369. # When they exist, we will set up a histogram- and 
  370. # multiple regression program (7d.inp and 2v.inp).
  371. # These are very similar, but not quite the same.
  372.  
  373. if [ $# -ge 1 ]
  374. then
  375.     echo -n "Processing your factors:"
  376.     cp 2d.inp 7d.inp
  377.     echo '/GROUP'  >> 7d.inp
  378.     for i            # Generate a code-stmnt
  379.     do
  380.         echo -n "$i..."
  381.         echo " CODES($i) ARE " >> 7d.inp
  382.         project $i < tmp$$.pre | 
  383.             tail +3 |
  384.             sort -u | sed -e 's/$/,/'  \
  385.                     -e '$s/,$/./' \
  386.                     -e '/\*/d' >> 7d.inp
  387.     done  
  388.     echo -n "Finishing up..."
  389.     var=`sed -e '1{s/\([^    ]\)    .*/\1./
  390.           q
  391.          }' < tmp$$.pre`    # Use 1st var as dependent
  392.     echo "VARIABLE=$var" >> 7d.inp
  393.     cp 7d.inp 2v.inp        # This is ends the similarity 7d=2v 
  394.     echo '/HISTOGRAM 
  395.               GROUPING=' >> 7d.inp
  396.     echo "/DESIGN DEPENDENT IS $var.
  397.               GROUPING ARE " >> 2v.inp
  398.     x=`echo $* | sed -e 's/  */,/g' -e 's/$/./'`
  399.     echo $x >> 7d.inp
  400.     echo $x >> 2v.inp
  401.  
  402.     echo '/END' >> 7d.inp
  403. fi 
  404. echo '/END' >> 2d.inp
  405.  
  406. echo "Done"
  407. echo "bmdp.prog contains a bmdp program to read bmdp.test and to
  408. generate simple statistics. 
  409.  
  410. Your next step(s) should be :
  411.  
  412.     2d < 2d.inp"
  413. if [ -f 7d.inp ]
  414. then
  415.     echo '     2v < 2v.inp'
  416.     echo '     2d < 2d.inp'
  417.     echo '     7d < 7d.inp'
  418. fi
  419. echo "and then use the files" *.inp "for future development."
  420.  
  421. rm -f tmp$$.pre
  422. \Rogue\Monster\
  423. else
  424.   echo "will not over write ./convert.src/Bmdp/pretobmdp.sh"
  425. fi
  426. if `test ! -d ./doc`
  427. then
  428.   mkdir ./doc
  429.   echo "mkdir ./doc"
  430. fi
  431. if `test ! -s ./doc/addcol.1`
  432. then
  433. echo "writting ./doc/addcol.1"
  434. cat > ./doc/addcol.1 << '\Rogue\Monster\'
  435. .\" Man page for addcol(1)
  436. .TH ADDCOL 1 "1. April 1989"
  437. .SH NAME
  438. addcol - addcol columns of a table
  439. .SH SYNOPSIS
  440. .B addcol
  441. .I newcolumn1 
  442. [
  443. .I newcolumn2
  444. \...
  445. ]
  446. .SH DESCRIPTION
  447. The
  448. .I addcol
  449. command adds new, empty columns to an existing reldb table.
  450. .I Project
  451. also does this, if nonexistent columns are named on its command line, but
  452. with
  453. .I addcol,
  454. mentioning existing columns is not needed.
  455. .SH "SEE ALSO"
  456. .BR reldb(1),\ rename(1),\ project(1)
  457. .SH "BUGS"
  458. None known.
  459. \Rogue\Monster\
  460. else
  461.   echo "will not over write ./doc/addcol.1"
  462. fi
  463. if `test ! -s ./doc/compute.1`
  464. then
  465. echo "writting ./doc/compute.1"
  466. cat > ./doc/compute.1 << '\Rogue\Monster\'
  467. .\" Man page for compute(1)
  468. .TH COMPUTE 1 "1. April 1989"
  469. .SH NAME
  470. compute - compute values into a table.
  471. .SH SYNOPSIS
  472. .B compute
  473. .I compute-statement
  474. [
  475. .I < data
  476. ]
  477. .SH DESCRIPTION
  478. .B compute
  479. reads columnar data from the standard input and computes new
  480. values into the columns according to the computational
  481. formula given. Arbitrarily complex
  482. expressions (c.f. 
  483. .I awk(1)
  484. )
  485. can be used, based on the column names.
  486. .LP
  487. This is best explained by way of an example. Suppose the file
  488. .I data
  489. contains the lines:
  490. .nf
  491. x       y       z       v       u       w       i
  492. -       -       -       -       -       -       -
  493. 0       1       2       3       4       *       6
  494. 1       2       3       4       5       **      7
  495. 2       3       4       5       6       ***     8
  496. 3       4       5       6       7       v       9
  497. 4       5       6       7       8       vi      10
  498. .fi
  499. where exactly one tab-character separates the columns.
  500. .LP
  501. The command 
  502. .I compute 'z = 2;
  503. .I v=2*i' < data
  504. yields 
  505. .nf
  506. x       y       z       v       u       w       i
  507. -       -       -       -       -       -       -
  508. 0       1       2       12      4       *       6
  509. 1       2       2       14      5       **      7
  510. 2       3       2       16      6       ***     8
  511. 3       4       2       18      7       v       9
  512. 4       5       2       20      8       vi      10
  513. .fi
  514. on the standard output.
  515. .LP
  516. More complex numerical computation commands can use
  517. if-statements, be placed on multiple lines etc. The format of
  518. the if-statements is like the expressions described in select(1).
  519. .SH "SEE ALSO"
  520. .BR reldb(1),\ awk(1),\ select(1).
  521. .SH BUGS
  522. .LP
  523. .B Compute
  524. simply calls upon 
  525. .I awk
  526. to do the work. Any bugs in 
  527. .I awk
  528. will be reflected in 
  529. .I compute.
  530. .LP
  531. Since the column names are translated into 
  532. .I awk
  533. variable names, column names are bound by the same rules as
  534. variable names in 
  535. .I awk.
  536. To be on the safe side, one should only use alphabetic 
  537. characters and underscores.
  538. International characters (e.g. from ISO 8859/1, upper half) will probably
  539. not work. Other symbols, such as a hyphen (minus) and asterisk will not work.
  540. .LP
  541. Some names are reserved 
  542. .I awk 
  543. symbols and should not be used for column names
  544. (e.g. if, for, length).
  545. .LP
  546. The single most difficult problem encountered with 
  547. .I compute
  548. and
  549. .I select
  550. is the error messages, which come from within
  551. .I awk.
  552. These are hard to trace, as 
  553. .I compute
  554. and 
  555. .I select
  556. generate awk-commands, which are stored in a temporary file, and
  557. this file is erased immediately after execution.
  558. .LP
  559. In BSD, one can suspend 
  560. .I compute
  561. (with ^Z) immediately after it is started and take a look at the 
  562. temporary file. Usually the error is completely obvious.
  563. .LP
  564. A good-natured soul should add a debug-option to 
  565. .I compute
  566. and 
  567. .I select,
  568. to allow output of this temporary file, e.g. to the terminal.
  569.  
  570. \Rogue\Monster\
  571. else
  572.   echo "will not over write ./doc/compute.1"
  573. fi
  574. if `test ! -s ./doc/count.1`
  575. then
  576. echo "writting ./doc/count.1"
  577. cat > ./doc/count.1 << '\Rogue\Monster\'
  578. .\" man-page for count(1).
  579. .TH COUNT 1 "1. April 1989"
  580. .SH NAME
  581. count - give a count of identical lines.
  582. .SH SYNOPSIS
  583. .B count
  584. [
  585. .I < data
  586. ]
  587. .SH DESCRIPTION
  588. .B Count
  589. reads a  (sorted)
  590. .I reldb
  591. table and counts the number of identical lines.
  592. The output consists of the input, where repetitions are
  593. output only once, but a count column is added to give
  594. the number of repetitions.
  595. .LP
  596. .I Count
  597. is typically used after
  598. .I sorttable,
  599. and is very useful for generating histograms. This program is essentially
  600. the 
  601. .I reldb
  602. analog of
  603. .I uniq.
  604. .SH "SEE ALSO"
  605. .BR reldb(1),\ sorttable(1),\ uniq(1).
  606. .SH BUGS
  607. .LP 
  608. No bugs are known.
  609. .LP
  610. After the program was written, it became obvious that it would have
  611. been trivial to implement using 
  612. .I uniq
  613. and
  614. .I sed.
  615. However, this beginner's C-program is much more efficient than that
  616. combination.
  617. \Rogue\Monster\
  618. else
  619.   echo "will not over write ./doc/count.1"
  620. fi
  621. if `test ! -s ./doc/dbe.1`
  622. then
  623. echo "writting ./doc/dbe.1"
  624. cat > ./doc/dbe.1 << '\Rogue\Monster\'
  625. .\" man-page for dbe(1).
  626. .TH DBE 1 "1. April 1989"
  627. .SH NAME
  628. dbe - database editor
  629. .LP
  630. dbe.add - add entries to reldb table
  631. .LP
  632. dbe.change - change entries in reldb table.
  633. .SH SYNOPSIS
  634. .B dbe.add
  635. .I  data
  636. .LP
  637. .B dbe.change
  638. .I  data
  639. .SH DESCRIPTION
  640. .LP
  641. A true database editor should allow easy editing of a table,
  642. including type checking, limits on numbers etc. Even better, it
  643. should be possible to edit several tables, going through them all
  644. simultaneously, using one or more key fields. 
  645. .LP
  646. None of the above has been implemented, although it would be fairly
  647. easy e.g. in lisp within GNU Emacs.
  648. .LP
  649. Instead, two shell scripts exist: 
  650. .I dbe.add
  651. for adding lines to a table, and
  652. .I dbe.change
  653. for going through all the lines in a table, with the option of
  654. reentering any field in any record.
  655. .LP
  656. To use 
  657. .I dbe.add,
  658. simply type
  659. the command followed by the name of a table. The table must exist.
  660. The script will then prompt for each field in the record. The user enters 
  661. values for the field and hits return in the end. After a record is complete,
  662. the program appends the record to the file. 
  663. .LP
  664. The program is terminated by typing ^C (hold down control while pressing c).
  665. .SH "SEE ALSO"
  666. .BR reldb(1).
  667. .SH BUGS
  668. .I Dbe
  669. is missing.
  670.  
  671. \Rogue\Monster\
  672. else
  673.   echo "will not over write ./doc/dbe.1"
  674. fi
  675. if `test ! -s ./doc/jointable.1`
  676. then
  677. echo "writting ./doc/jointable.1"
  678. cat > ./doc/jointable.1 << '\Rogue\Monster\'
  679. .\" Man page for jointable(1)
  680. .TH JOINTABLE 1 "1. April 1989"
  681. .SH NAME
  682. jointable - relational join on two tables
  683. .SH SYNOPSIS
  684. .B jointable
  685. .I file1\ file2
  686. [
  687. .I >\ result
  688. ]
  689. .SH DESCRIPTION
  690. .LP
  691. .B Jointable
  692. takes two input files and joins them ("side by side"), using
  693. the first column of each as a key. 
  694. .LP
  695. A line in one file which does not
  696. have a matching line in the other file is not output. Thus
  697. .I jointable
  698. can be used with 
  699. .I sorttable
  700. to select lines from either or both files. This will tend to
  701. be faster than
  702. .I select
  703. on large file, but requires both files to be sorted alphabetically.
  704. .LP
  705. The current implementation of 
  706. .I jointable
  707. is simply a shell script which calls 
  708. .I join(1).
  709. Any bugs in 
  710. .I join
  711. will therefore also be reflected in 
  712. .I jointable.
  713. .SH "SEE ALSO"
  714. .BR reldb(1),\ sorttable(1),\ select(1),\ plokk(1).
  715. .SH BUGS
  716. .LP
  717. .I Jointable
  718. requires both files first to be sorted alphabetically,
  719. .B not\ numerically
  720. using 
  721. .I sorttable.
  722. .LP
  723. Running
  724. .I sorttable
  725. and 
  726. .I jointable
  727. to select lines from files
  728. may get somewhat slow. See plokk(1) for alternate ways to select
  729. lines based on values in a key field. See 
  730. .I select
  731. for a much more flexible method of selecting lines.
  732. .LP
  733. Bugs have been reported when using 
  734. .I jointable
  735. with larger files on a Sun 3/50 running SunOs 4.0. 
  736. These bugs do not occur on Sun 4's or on earlier versions of 
  737. SunOs and are likely due to bugs in 
  738. .I join(1)
  739. on the Sun 3/50.
  740. \Rogue\Monster\
  741. else
  742.   echo "will not over write ./doc/jointable.1"
  743. fi
  744. if `test ! -s ./doc/matrix.1`
  745. then
  746. echo "writting ./doc/matrix.1"
  747. cat > ./doc/matrix.1 << '\Rogue\Monster\'
  748. .\" man-page for matrix(1).
  749. .TH MATRIX 1 "1. April 1989"
  750. .SH NAME
  751. matrix - transform (z,x,y)-style data to matrix format.
  752. .SH SYNOPSIS
  753. .B matrix
  754. .I -f format
  755. [
  756. .I < data
  757. ]
  758. .SH DESCRIPTION
  759. .B matrix
  760. reads a three-column table (as written by count(1)) from the standard input and 
  761. transforms it to matrix format by summing the first 
  762. column into a matrix indexed by the second and third column.
  763. .LP
  764. The format option should be used to obtain pretty output. It refers to
  765. the format of all columns after the first one.
  766. .LP
  767. The z-columns (typically frequencies) can be any real numbers. The
  768. coordinate columns can be arbitrary positive integers, although 
  769. .I matrix
  770. does put limits on their size.
  771. .LP
  772. This is best explained by way of an example. Suppose the file
  773. .I data
  774. contains the lines:
  775. .nf
  776. count   x       y 
  777. -----   -       -
  778. 1       1       2
  779. 1       1       3
  780. 2       3       4
  781. 2       4       5
  782. 2       4       6
  783. .fi
  784. where exactly one tab-character separates the columns.
  785. .LP
  786. The command 
  787. .I matrix 
  788. \fI"\\t%.0f" < data\fP
  789. yields 
  790. .nf
  791. y       x1      x2      x3      x4
  792. -       --      --      --      --
  793. 2       1       0       0       0
  794. 3       1       0       0       0
  795. 4       0       0       2       0
  796. 5       0       0       0       2
  797. 6       0       0       0       2
  798. .fi
  799. on the standard output.
  800. .LP
  801. The input does not need to be sorted in any way.
  802. .SH "SEE ALSO"
  803. .BR reldb(1),\ count(1).
  804. .SH BUGS
  805. .LP
  806. .B Matrix
  807. has hardwired dimensions. This should definitely be changed.
  808. .LP
  809. Other options may be available, e.g. to control whether lines
  810. consisting of all zeros 
  811. are output. Check the code.
  812. \Rogue\Monster\
  813. else
  814.   echo "will not over write ./doc/matrix.1"
  815. fi
  816. if `test ! -s ./doc/plokk.1`
  817. then
  818. echo "writting ./doc/plokk.1"
  819. cat > ./doc/plokk.1 << '\Rogue\Monster\'
  820. .\" Man page for plokk(1)
  821. .TH PLOKK 1 "1. April 1989"
  822. .SH NAME
  823. plokk - 'pluck' lines from a file.
  824. .SH SYNOPSIS
  825. .B plokk
  826. .I selfile < datafile
  827. [
  828. .I >\ result
  829. ]
  830. .LP
  831. .B bplokk
  832. .I selfile < datafile
  833. [
  834. .I >\ result
  835. ]
  836. .SH DESCRIPTION
  837. .LP
  838. .B Plokk
  839. uses a 
  840. .I selection file
  841. to decide while lines to select from a 
  842. .I datafile.
  843. It is very fast and is often used in place of
  844. .I select(1)
  845. or a
  846. .I sorttable(1)/jointable(1)
  847. combination.
  848. .LP
  849. .I Plokk
  850. is useful when selecting according to values in a fixed column
  851. of the datafile. The datacolumn of interest must be the first column
  852. of the data (see
  853. .I project(1)).
  854. The selection must be based on numerical values (see also BUGS, below).
  855. .LP
  856. The first column of 
  857. .I selfile
  858. is assumed to contain numbers corresponding to values to be selected
  859. from the datafile.
  860. .LP
  861. .I Plokk
  862. does not require any sorting of the files.  However,
  863. there is a limit on the largest number which can be selected.
  864. .LP
  865. .I Bplokk
  866. (big
  867. .I plokk)
  868. can handle more arbitrary numbers (even text) in the 
  869. .I selection\ file,
  870. but in this case there is a limit on the size of the
  871. .I selection file.
  872. .I Bplokk requires the
  873. .I selection file
  874. to have only one column, the column of values to be selected.
  875. .SH "SEE ALSO"
  876. .BR reldb(1),\ jointable(1),\ sorttable(1),\ select(1),\ fgrep(1).
  877. .SH "BUGS AND LIMITATIONS"
  878. .LP
  879. .I Plokk
  880. works by reading the numbers in the 
  881. .I selection file 
  882. and inserting '1'
  883. into  a vector for elements corresponding to values to be selected.
  884. The check to see if a line is to be selected therefore
  885. only requires a single lookup into a vector.
  886. This is extremely fast, even for large datafiles,
  887. but the dimension of the vector limits the numerical size of 
  888. indices to be selected.
  889. .LP
  890. .I Bplokk
  891. overcomes the limitation of 
  892. .I plokk,
  893. by using the 
  894. .I selection file 
  895. for building a command for 
  896. .I egrep,
  897. to search for strings at the beginning of lines in the datafile.
  898. The shell on the user's system will limit the size of the search
  899. string, which implies a limit on the number of items in the
  900. .I selection file.
  901. .LP
  902. The name of the command has an Icelandic origin, and is used to describe
  903. .I pulling 
  904. lice out of hair, 
  905. .I plucking 
  906. chicken etc, c.f. 
  907. .I pluck.
  908. .LP
  909. Note that
  910. .I fgrep(1)
  911. can be used with the same input as
  912. .I bplokk.
  913. This may alleviate some of the limitations of the number of
  914. search-items in 
  915. .I bplokk,
  916. but
  917. .I fgrep
  918. will of course search for the search-strings anywhere in the data
  919. file, not just in the first column.
  920. \Rogue\Monster\
  921. else
  922.   echo "will not over write ./doc/plokk.1"
  923. fi
  924. if `test ! -s ./doc/project.1`
  925. then
  926. echo "writting ./doc/project.1"
  927. cat > ./doc/project.1 << '\Rogue\Monster\'
  928. .\" Man page for project(1)
  929. .TH PROJECT 1 "1. April 1989"
  930. .SH NAME
  931. project - project columns from table
  932. .SH SYNOPSIS
  933. .B project
  934. .I columns
  935. [
  936. .I < data
  937. ]
  938. .SH DESCRIPTION
  939. .B project
  940. reads columnar data from the standard input and outputs the
  941. named columns.
  942. .LP
  943. This is best explained by way of an example. Suppose the file
  944. .I data
  945. contains the lines:
  946. .nf
  947. xcol    y       z       v       u       w       i
  948. ----    -       -       -       -       -       -
  949. 0       1       2       3       4       *       6
  950. 1       2       3       4       5       **      7
  951. 2       3       4       5       6       ***     8
  952. 3       4       5       6       7       v       9
  953. 4       5       6       7       8       vi      10
  954. .fi
  955. where exactly one tab-character separates the columns.
  956. .LP
  957. The command 
  958. .I project y v xcol < data
  959. yields 
  960. .nf
  961. y       v       xcol
  962. -       -       ----
  963. 1       3       0
  964. 1       2       3
  965. 2       3       4
  966. 3       4       5
  967. 4       5       6
  968. .fi
  969. on the standard output.
  970. .LP
  971. .B Project 
  972. is typically used with other reldb commands such as select, in which
  973. case the output from one command is piped into another.
  974. .SH "SEE ALSO"
  975. .BR reldb(1)
  976. .SH BUGS
  977. .LP
  978. .B Project
  979. uses a fixed size matrix for storing column names. This will overflow
  980. when too many names are given on the command line. No warning is given.
  981. \Rogue\Monster\
  982. else
  983.   echo "will not over write ./doc/project.1"
  984. fi
  985. if `test ! -s ./doc/reldb.1`
  986. then
  987. echo "writting ./doc/reldb.1"
  988. cat > ./doc/reldb.1 << '\Rogue\Monster\'
  989. .\" Man page for reldb(1). gunnar@hafro.is 1. april, 1989.
  990. .TH RELDB 1 "1. April 1989"
  991. .SH NAME
  992. reldb - programs for simple relational database operations
  993. .SH DESCRIPTION
  994. All 
  995. .I reldb 
  996. programs
  997. read columnar data from the standard input and write to the
  998. standard output.
  999. .LP
  1000. All database operations are based on the Unix notion of
  1001. pipes and filters. Thus, programs tend to be small, doing one
  1002. task. The output from any one program can be piped into another.
  1003. .LP
  1004. A data file is a simple ascii file, with columns separated by a
  1005. single tab. Thus, two tabs in a row denote an empty field
  1006. (e.g. a missing value). Data fields can contain anything,
  1007. character or numbers,
  1008. although some commands will strip the 8th bit since the 
  1009. Unix tools called upon will do so. Naturally, there is no built-in
  1010. notion of maximum field-, record- or file-length.
  1011. .LP
  1012. The primary problem with flat Unix files is the loss of the
  1013. data dictionary concept. This is partially solved by using the first two lines
  1014. in any file as a header, where the first line contains the
  1015. column names (separated by tabs) and the second line contains
  1016. a series of dashes. This allows commands to operate on columns by their
  1017. name, regardless of their position in the input file.
  1018. .LP
  1019. The only restriction on the format of the files is that a file must
  1020. contain the same fixed number of tabs  in every line.
  1021. .LP
  1022. This is best explained by way of an example:
  1023. .nf
  1024. xcol    y       z       v       u       w       i
  1025. ----    -       -       -       -       -       -
  1026. 0       1       2       3       4       *       6
  1027. 1       2       3       4       5       **      7
  1028. 2       3       4       5       6       ***     8
  1029. 3       4       5       6       7       v       9
  1030. 4       5       6       7       8       vi      10
  1031. .fi
  1032. .LP
  1033. When the fields are long, the columns will not look "straight" as in the
  1034. above example, but that is irrelevant. The only important element is
  1035. that a tab always separates the columns, and there are an equal number
  1036. of tabs in every line.
  1037. .LP
  1038. .I Reldb 
  1039. commands can read this file from the standard input. Thus, one can
  1040. .I select 
  1041. lines from the file
  1042. (c.f.
  1043. .I grep(1)), 
  1044. .I project 
  1045. columns (c.f. 
  1046. .I cut(1)), use 
  1047. .I jointable 
  1048. to join it (sideways, like
  1049. .I join(1)
  1050. ) with another file or use 
  1051. .I union 
  1052. to concatenate two such files (like
  1053. .I cat (1)
  1054. ). Other operations include 
  1055. .I rename 
  1056. to rename columns, 
  1057. .I compute 
  1058. to
  1059. compute new values into columns, 
  1060. .I addcol 
  1061. to add columns into a table, 
  1062. .I sorttable
  1063. to sort a table, etc. etc.
  1064. .LP
  1065. Data from a
  1066. .I reldb
  1067. file can be trivially piped to "ordinary" Unix programs, via
  1068. the 
  1069. .I tail\ +3 < data
  1070. command. In particular, this allows a very easy interface with
  1071. the excellent collection of statistical routines by Gary Perlman,
  1072. .I |Stat,
  1073. (previously 
  1074. .I Unix|Stat), 
  1075. also available as freeware.
  1076. .LP
  1077. The best feature of the 
  1078. .I reldb 
  1079. approach is the possibility of combining programs using Unix pipes.
  1080. Thus one can first 
  1081. .I select 
  1082. lines where 
  1083. .I 'quantity' 
  1084. is at least one, and 
  1085. .I project 
  1086. columns 
  1087. .I 'price' and 
  1088. .I 'quantity' 
  1089. from the output:
  1090. .nf
  1091. .ce
  1092. .I
  1093. select 'quantity >= 1' < data | project price quantity
  1094. .fi
  1095. Similarly, one can 
  1096. .I compute
  1097. new values into columns, 
  1098. .I select 
  1099. lines, 
  1100. .I project
  1101. columns and pipe the result through 
  1102. .I scat
  1103. to prot the results.
  1104. .SH "SEE ALSO"
  1105. .BR project(1),\ select(1),\ addcol(1),\ rename(1),
  1106. .BR sorttable(1),\ compute(1),\ plokk(1),\ subtotal(1),
  1107. .BR matrix(1),\ number(1),\ check(1),\ dbe(1),
  1108. .BR testdb(1),\ testgr(1),
  1109. .BR |Stat(1).
  1110. .SH BUGS
  1111. .LP
  1112. Probably very many. See each command. 
  1113. .LP
  1114. The column names should be restricted to ascii characters and underscores.
  1115. On some systems international characters (i.e. ISO 8859/1, "upper half") 
  1116. will work,
  1117. but a number of Unix implementations have awk's which strip the
  1118. 8th bit. Furthermore, symbols such as a hyphen and an asterics will be
  1119. misinterpreted in 
  1120. .I compute
  1121. and
  1122. .I select,
  1123. which call upon
  1124. .I awk(1)
  1125. to do their work, using the column names as variable names. Thus the
  1126. column names are bound to the same rules as variable names in 
  1127. .I awk.
  1128. .LP
  1129. Most of the commands have their
  1130. .I man-
  1131. page, but there will always be some that are missing, since programs
  1132. will always be written before their documentation, contrary to
  1133. what tends to be called good practise.
  1134. .SH "ACKNOWLEDGEMENTS AND HISTORY"
  1135. .LP
  1136. These programs would never have been written  had  VenturCom
  1137. Inc. not refused to port their Prelude package to our (then)
  1138. central computer. This taught us  the  lesson  that  one  is
  1139. never independent of hardware vendors unless one is independent of 
  1140. software vendors. The lack of Prelude
  1141. on the new computer made us think about just how hard it would be
  1142. to rewrite the bare essentials of a rdbs (here called
  1143. .I project,\ select,\ union 
  1144. and
  1145. .I jointable).
  1146. We found this a trivial task and in time a large number of other 
  1147. programs followed. All of them were written as they were needed and
  1148. most of them are based on corresponding Unix tools, making the "writing"
  1149. incredibly easy in each case. Having gone through this, 
  1150. we now very much question the wisdom
  1151. of everyone writing in proprietary 4GL languages and using expensive dbms for
  1152. simple applications.
  1153. .LP
  1154. .I Prelude
  1155. is a much more complete system than
  1156. .I reldb,
  1157. but the principal elements look much the same as 
  1158. .I reldb
  1159. was modeled to resemble a very early
  1160. version of
  1161. .I Prelude.
  1162. A user wanting a complete and bug-free rdbs might want to contact
  1163. .I VenturCom, 
  1164. but of course
  1165. .I reldb
  1166. is free and the source code is available, to be readily ported to any
  1167. system (no, we do not have any ties with 
  1168. .I VenturCom,
  1169. other than being a fairly happy customer).
  1170. .LP
  1171. This approach, although very cheap in manpower, has its problems in terms
  1172. of integration, performance and elegance of individual programs. Overall, the
  1173. system has been found to be extremely portable, as it is based
  1174. mainly on shell scripts, which call corresponding Unix tools, after
  1175. dealing with the header lines. Efficiency, although nowhere nearly the 
  1176. best possible, has rarely been a bottleneck.
  1177. .LP
  1178. Bugs (with suggested corrections, please) should be reported to
  1179. gunnar@hafro.is (Internet) or uunet!mcvax!hafro!gunnar (Uucp).
  1180. \Rogue\Monster\
  1181. else
  1182.   echo "will not over write ./doc/reldb.1"
  1183. fi
  1184. if `test ! -s ./doc/rename.1`
  1185. then
  1186. echo "writting ./doc/rename.1"
  1187. cat > ./doc/rename.1 << '\Rogue\Monster\'
  1188. .\" Man page for rename(1)
  1189. .TH RENAME 1 "1. April 1989"
  1190. .SH NAME
  1191. rename - rename columns of a table
  1192. .SH SYNOPSIS
  1193. .B rename
  1194. .I oldcolumn1 newcolumn1 
  1195. [
  1196. .I old2 new2 ...
  1197. ]
  1198. [
  1199. .I < data
  1200. ]
  1201. .SH DESCRIPTION
  1202. Self-explanatory.
  1203. .SH "SEE ALSO"
  1204. .BR reldb(1),\ addcol(1),\ project(1)
  1205. .SH BUGS
  1206. None known.
  1207. \Rogue\Monster\
  1208. else
  1209.   echo "will not over write ./doc/rename.1"
  1210. fi
  1211. if `test ! -s ./doc/scat.1`
  1212. then
  1213. echo "writting ./doc/scat.1"
  1214. cat > ./doc/scat.1 << '\Rogue\Monster\'
  1215. .\" Man page for scat(1l)
  1216. .TH SCAT 1L "1. April 1989"
  1217. .SH NAME
  1218. scat \- line drawings with points or labels, based on data
  1219. .SH SYNOPSIS
  1220. .B scat
  1221. [
  1222. .B \-x
  1223. .I m,n,l
  1224. ]
  1225. [
  1226. .B \-y
  1227. .I m,n,l
  1228. ]
  1229. [
  1230. .B \-w
  1231. m,n,l,o
  1232. ]
  1233. [
  1234. .B \-X
  1235. text
  1236. ]
  1237. [
  1238. .B \-Y
  1239. text
  1240. ]
  1241. [
  1242. .B \-H
  1243. text
  1244. ]
  1245. [
  1246. .B \-F
  1247. "x format"
  1248. ]
  1249. [
  1250. .B \-F
  1251. "y format"
  1252. ]
  1253. [
  1254. .B \-c
  1255. ]
  1256. [
  1257. .B \-h
  1258. ]
  1259. [
  1260. .B \-e 
  1261. ]
  1262. [
  1263. .B \-E 
  1264. ]
  1265. [
  1266. .B \-l
  1267. name
  1268. ]
  1269. [
  1270. .B \-L
  1271. name
  1272. ]
  1273. [
  1274. .B \-d
  1275. number
  1276. ]
  1277. .SH DESCRIPTION
  1278. .B scat
  1279. (scattergram) reads data from the standard input to generate 
  1280. .BR plot(5) 
  1281. commands 
  1282. on the standard output. These can be read by the 
  1283. .BR plot(1) 
  1284. filters to produce a graph on the desired device.
  1285. .LP
  1286. .B Scat
  1287. is designed so that running it with no options at all will
  1288. result in a useful, though possibly not-so-pretty graph, and the options
  1289. deal mostly with making the graph look nicer.
  1290. .LP
  1291. Data must be in columns, with a single tab character between columns.
  1292. A missing value is thus denoted by two tabs. The first column is 
  1293. taken to be the X-axis and is therefore assumed to be numeric.
  1294. .LP
  1295. The first line of the data must contain column names, separated by tabs.
  1296. The second line consists of dashes, to separate the first line
  1297. from the data.
  1298. .LP
  1299. This is best explained by way of an example:
  1300. .nf
  1301. xcol    y       z       v       u       w       i
  1302. -       -       -       -       -       -       -
  1303. 0       1       2       3       4       *       6
  1304. 1       2       3       4       5       **      7
  1305. 2       3       4       5       6       ***     8
  1306. 3       4       5       6       7       v       9
  1307. 4       5       6       7       8       vi      10
  1308. .fi
  1309. .LP
  1310. When no options are given, 
  1311. .B scat
  1312. assumes that the user wants a single figure, where each column after
  1313. the first is plotted against the first. 
  1314. .LP
  1315. In the simplest case, e.g. with only the xcol and y columns above,
  1316. and no options,
  1317. .B scat
  1318. will draw lines through the points (xcol,y), using the data to
  1319. compute bounds for the graph, no figurecaption will be given, and the
  1320. column names,  "xcol" and "y", will be used as axes labels.
  1321. .LP
  1322. In the above example, the
  1323. .B w
  1324. column is nonnumeric, so an option must be given to indicate it
  1325. as a label column. The labels will be placed at the points (xcol,u).
  1326. All the other columns will be plotted against 
  1327. .B xcol.
  1328. .LP
  1329. When a y-value is missing, no line will be drawn through that point
  1330. (i.e. two line segments will be skipped). A missing value for a 
  1331. label is simply ignored.
  1332. .SH OPTIONS
  1333. .LP
  1334. Options are quite numerous and follow the strict Sys V format.
  1335. .TP
  1336. .BI \-x\ m,n,l
  1337. Numerical bounds on the horizontal axis (minimum, 
  1338. maximum and interval width). If missing, bounds based on the data will be used.
  1339. .TP
  1340. .BI \-y\ m,n,l
  1341. Corresponding bounds for the y axis.
  1342. .TP
  1343. .BI \-w\ m,n,l,o
  1344. Window bounds  (minx, miny, maxx,maxy). These define the region
  1345. of the plot to be used for the figure. For example, to plot in
  1346. the upper right quadrant use:
  1347. .I \-w\ 0.5,0.5,1.0,1.0 .
  1348. If missing, (0,0) to (1,1) is used. (0,0) is the lower left hand corner.
  1349. .TP
  1350. .BI \-X\ text 
  1351. Text for X axis.  If missing, the name of the first column is used.
  1352. .I text
  1353. can be an arbitrary string (within quotes, if needed).
  1354. .TP
  1355. .BI \-Y\ text  
  1356. Text for Y axis. If missing, the name of the second column is used.
  1357. .TP
  1358. .BI \-H\ text  
  1359. Figurecaption. Text to be placed above the figure. If missing, no
  1360. figurecaption is given.
  1361. .TP
  1362. .BI \-F\ xformat
  1363. Format for numbers on x axis. For example, 
  1364. .B
  1365. -F "x %.2f"
  1366. will result in the numbers on the x axis having
  1367. two digits after the decimal place. If missing, a fixed default format is
  1368. used.
  1369. .TP
  1370. .BI \-F\ yformat
  1371. Format for numbers on y axis.
  1372. .TP
  1373. .BI \-c       
  1374. Use colors. If not used, dashed and dotted lines will be used to
  1375. distinguish between different columns in the input.
  1376. .TP
  1377. .BI \-E      
  1378. Use extensions to the plot(5) command set. This is needed in order
  1379. to accommodate rotation of text (y-axis) and centering of labels (header,
  1380. x-axis and points), none of which is supported in the base command set.
  1381. .TP
  1382. .BI \-e      
  1383. Don't erase before plotting. This is useful when several pictures are
  1384. to be plotted on the same piece of paper (or screenfull or...). In this
  1385. case, the 
  1386. .I \-e
  1387. option is used for all figures after the first one.
  1388. .TP
  1389. .BI \-l\ name
  1390. Name of y column not to draw lines for. This will result in
  1391. small points being drawn for each (x,y) pair, unless a label
  1392. column is specified for this y-column. The default is always to
  1393. draw lines between points.
  1394. .TP
  1395. .BI \-L\ name
  1396. Name of label-column. When used, column
  1397. .I name
  1398. must contain labels to be used. These labels will be placed at
  1399. points (x,y), where x is taken from the first column and y
  1400. is the column preceding the column
  1401. .I name.
  1402. .TP
  1403. .BI \-d\ number
  1404. Debug level. Higher levels give more output.
  1405. .SH "SEE ALSO"
  1406. .BR plot (1),
  1407. .BR plot(5)
  1408. .SH BUGS
  1409. .LP
  1410. .B Scat
  1411. stores all points internally. Strictly speaking this is not needed when
  1412. the data bounds are given, but that would require quite a bit of reprogramming.
  1413. .LP
  1414. The methods of setting up the default axes should be replaced by one which
  1415. gives reasonable numbers by default. The current method uses the absolute 
  1416. maximum and minimum from the data. This tends to give ridiculous
  1417. numbers, although they will of course handle the figure.
  1418. .LP
  1419. As
  1420. .I scat
  1421. is tied to the 
  1422. .I plot(5)
  1423. command set, it cannot do miracles. Simple extensions to this
  1424. command set do wonders, however. These have been implemented in
  1425. the filters in this distribution and will be used when the 
  1426. .I \-E
  1427. option is used in 
  1428. .I scat.
  1429. \Rogue\Monster\
  1430. else
  1431.   echo "will not over write ./doc/scat.1"
  1432. fi
  1433. if `test ! -s ./doc/select.1`
  1434. then
  1435. echo "writting ./doc/select.1"
  1436. cat > ./doc/select.1 << '\Rogue\Monster\'
  1437. .\" Man page for select(1)
  1438. .TH SELECT 1 "1. April 1989"
  1439. .SH NAME
  1440. select - select lines from a table.
  1441. .SH SYNOPSIS
  1442. .B select
  1443. .I criterion
  1444. [
  1445. .I < data
  1446. ]
  1447. .SH DESCRIPTION
  1448. .B select
  1449. reads columnar data from the standard input and outputs those
  1450. lines satisfying the given criterion. Arbitrarily complex
  1451. expressions (c.f. 
  1452. .I awk(1)
  1453. )
  1454. can be used, based on the column names.
  1455. .LP
  1456. This is best explained by way of an example. Suppose the file
  1457. .I data
  1458. contains the lines:
  1459. .nf
  1460. x       y       z       v       u       w       i
  1461. -       -       -       -       -       -       -
  1462. 0       1       2       3       4       *       6
  1463. 1       2       3       4       5       **      7
  1464. 2       3       4       5       6       ***     8
  1465. 3       4       5       6       7       v       9
  1466. 4       5       6       7       8       vi      10
  1467. .fi
  1468. where exactly one tab-character separates the columns.
  1469. .LP
  1470. The command 
  1471. .I select 'z == 2' < data
  1472. (where == is the usual Unix notation for 'equal') yields 
  1473. .nf
  1474. x       y       z       v       u       w       i
  1475. -       -       -       -       -       -       -
  1476. 0       1       2       3       4       *       6
  1477. .fi
  1478. on the standard output.
  1479. .LP
  1480. Other numerical selection commands include 
  1481. .B < > >= <=
  1482. and these can be used together, with
  1483. .B &&
  1484. (and),
  1485. .B ||
  1486. (or),
  1487. using parenthesis as needed.
  1488. .LP
  1489. The command
  1490. .I select 'z > 2 && 
  1491. .I v <= 5' < data'
  1492. will give
  1493. .nf
  1494. x       y       z       v       u       w       i
  1495. -       -       -       -       -       -       -
  1496. 1       2       3       4       5       **      7
  1497. 2       3       4       5       6       ***     8
  1498. .fi
  1499. This last command should be read: select those lines where the z column
  1500. is (strictly) larger than 2 and (at the same time) the v column is
  1501. less than or equal to 5.
  1502. .SH "SEE ALSO"
  1503. .BR reldb(1),\ plokk(1),\ awk(1),\ grep(1).
  1504. .SH BUGS
  1505. .LP
  1506. .B Select
  1507. simply calls upon 
  1508. .I awk
  1509. to do the work. Any bugs in 
  1510. .I awk
  1511. will be reflected in 
  1512. .I select.
  1513. .LP
  1514. Since the column names are translated into 
  1515. .I awk
  1516. variable names, column names are bound by the same rules as
  1517. variable names in 
  1518. .I awk.
  1519. To be on the safe side, one should only use alphabetic 
  1520. characters and underscores.
  1521. International characters (e.g. from ISO 8859/1, upper half) will probably
  1522. not work. Other symbols, such as a hyphen (minus) and asterisk will not work.
  1523. .LP
  1524. Some names are reserved 
  1525. .I awk 
  1526. symbols and should not be used for column names
  1527. (e.g. if, for, length).
  1528. \Rogue\Monster\
  1529. else
  1530.   echo "will not over write ./doc/select.1"
  1531. fi
  1532. if `test ! -s ./doc/sorttable.1`
  1533. then
  1534. echo "writting ./doc/sorttable.1"
  1535. cat > ./doc/sorttable.1 << '\Rogue\Monster\'
  1536. .\" Man page for sorttable(1)
  1537. .TH SORTTABLE 1 "1. April 1989"
  1538. .SH NAME
  1539. sorttable - sort a table
  1540. .SH SYNOPSIS
  1541. .B sorttable
  1542. [
  1543. .I -n
  1544. ]
  1545. .I < file
  1546. [
  1547. .I >\ result
  1548. ]
  1549. .SH DESCRIPTION
  1550. .LP
  1551. .B Sorttable
  1552. takes an input file and sorts it, using
  1553. either alphabetic sort (default)  or numeric sort (-n option).
  1554. .LP
  1555. The current implementation of 
  1556. .I sorttable
  1557. is simply a shell script which calls 
  1558. .I sort(1).
  1559. .LP
  1560. Note that the 
  1561. .I -n
  1562. option is only useful for generating pretty output. It should 
  1563. .I not
  1564. be used with
  1565. .I jointable.
  1566. .SH "SEE ALSO"
  1567. .BR reldb(1).
  1568. .SH BUGS
  1569. .LP
  1570. .I Sorttable
  1571. only reads the standard input, so '<' must be used.
  1572. .LP
  1573. When using numeric sort (-n), only the first column is sorted numerically.
  1574. For fixed vales of the first column, the rest of the line is sorted 
  1575. alphabetically.
  1576. \Rogue\Monster\
  1577. else
  1578.   echo "will not over write ./doc/sorttable.1"
  1579. fi
  1580. if `test ! -s ./doc/subtotal.1`
  1581. then
  1582. echo "writting ./doc/subtotal.1"
  1583. cat > ./doc/subtotal.1 << '\Rogue\Monster\'
  1584. .\" man-page for subtotal(1).
  1585. .TH SUBTOTAL 1 "1. April 1989"
  1586. .SH NAME
  1587. subtotal - subtotal values of some columns for fixed values of other columns.
  1588. .SH SYNOPSIS
  1589. .B subtotal
  1590. .I by bycolumnlist 
  1591. .I on oncolumnlist
  1592. [
  1593. .I < data
  1594. ]
  1595. .SH DESCRIPTION
  1596. .B subtotal
  1597. reads columnar data from the standard input and subtotals 
  1598. the by-columns  for fixed values of the on-columns.
  1599. .LP
  1600. This is best explained by way of an example. Suppose the file
  1601. .I data
  1602. contains the lines:
  1603. .nf
  1604. x       y       z       v
  1605. -       -       -       -
  1606. 1       1       2       3
  1607. 1       1       3       4
  1608. 2       3       4       5
  1609. 2       4       5       6
  1610. 2       4       6       7
  1611. .fi
  1612. where exactly one tab-character separates the columns.
  1613. .LP
  1614. The command 
  1615. .I subtotal by x y on z v < data
  1616. yields 
  1617. .nf
  1618. x       y       z       v
  1619. -       -       -       -
  1620. 1       1       5       7
  1621. 2       3       4       5
  1622. 2       4       11      13
  1623. .fi
  1624. on the standard output.
  1625. .LP
  1626. Note that the input must be sorted on the by-columns in some fashion,
  1627. so that all instances of equivalent lines are adjacent.
  1628. .LP
  1629. On-columns and by-columns can be intermixed in the input. Other columns
  1630. in the input are ignored in the computations and are not output.
  1631. .SH "SEE ALSO"
  1632. .BR reldb(1),\ sorttable(1).
  1633. .SH BUGS
  1634. .LP
  1635. .B Subtotal
  1636. calls upon  two other programs,
  1637. .I project 
  1638. and
  1639. .I addcol
  1640. to do the work. This is inefficient but the inefficiency is rarely noticable.\Rogue\Monster\
  1641. else
  1642.   echo "will not over write ./doc/subtotal.1"
  1643. fi
  1644. if `test ! -s ./doc/union.1`
  1645. then
  1646. echo "writting ./doc/union.1"
  1647. cat > ./doc/union.1 << '\Rogue\Monster\'
  1648. .\" Man page for union(1)
  1649. .TH UNION 1 "1. April 1989"
  1650. .SH NAME
  1651. union - appends one table to another
  1652. .SH SYNOPSIS
  1653. .B union
  1654. .I file1\ file2
  1655. [
  1656. .I >\ outputfile
  1657. ]
  1658. .SH DESCRIPTION
  1659. .LP
  1660. The 
  1661. .I union
  1662. command simply concatenates two files, appending the second to the
  1663. first, but using only the header of the first file.
  1664. .LP
  1665. With the two files,
  1666. .I data1:
  1667. .nf
  1668. first   second  third
  1669. -----   ------  -----
  1670. 1       3       0
  1671. 1       2       3
  1672. .fi
  1673. and 
  1674. .I data2:
  1675. .nf
  1676. first   second  third
  1677. -----   ------  -----
  1678. 2       3       4
  1679. 3       4       5
  1680. 4       5       6
  1681. .fi
  1682. the 
  1683. command
  1684. .BI union\ data1\ data2
  1685. yields:
  1686. .nf
  1687. first   second  third
  1688. -----   ------  -----
  1689. 1       3       0
  1690. 1       2       3
  1691. 2       3       4
  1692. 3       4       5
  1693. 4       5       6
  1694. .fi
  1695. on the standard output.
  1696. .LP
  1697. Note that the two input files must have the same columns, 
  1698. in the same order.
  1699. .SH "SEE ALSO"
  1700. .BR reldb(1)\ cat(1).
  1701. \Rogue\Monster\
  1702. else
  1703.   echo "will not over write ./doc/union.1"
  1704. fi
  1705. if `test ! -s ./doc/Makefile`
  1706. then
  1707. echo "writting ./doc/Makefile"
  1708. cat > ./doc/Makefile << '\Rogue\Monster\'
  1709. MANDIR=/usr/man/man1
  1710. MANPAGES=addcol.1 check.1 compute.1 count.1 dbe.1 invert.1 \
  1711.     jointable.1 \
  1712.     math.1 matrix.1 \
  1713.     number.1 \
  1714.     plokk.1 project.1 \
  1715.     recode.1 \
  1716.     reldb.1 rename.1 scat.1 select.1 \
  1717.     testdb.1 testgr.1 \
  1718.     sorttable.1 subtotal.1 union.1
  1719. install: $(MANPAGES)
  1720.     cp $(MANPAGES) $(MANDIR)
  1721. uninstall: 
  1722.     cd $(MANDIR);rm -f $(MANPAGES)
  1723. \Rogue\Monster\
  1724. else
  1725.   echo "will not over write ./doc/Makefile"
  1726. fi
  1727. if `test ! -s ./doc/invert.1`
  1728. then
  1729. echo "writting ./doc/invert.1"
  1730. cat > ./doc/invert.1 << '\Rogue\Monster\'
  1731. .\" man-page for invert(1).
  1732. .TH INVERT 1 "1. April 1989"
  1733. .SH NAME
  1734. invert - matrix data to (z,x,y)-style data.
  1735. .SH SYNOPSIS
  1736. .B invert
  1737. [
  1738. .I < data
  1739. ]
  1740. .SH DESCRIPTION
  1741. .B invert
  1742. reads a 
  1743. matrix-style table and outputs a
  1744. three-column table.
  1745. .LP
  1746. The contents of the table
  1747. can be any real numbers. 
  1748. .LP
  1749. This is best explained by way of an example. Suppose the file
  1750. .I data
  1751. contains the lines:
  1752. .nf
  1753. y       1       2       3       4
  1754. -       -       -       -       -
  1755. 2       1       0       0       0
  1756. 3       1       0       0       0
  1757. 4       0       0       2       0
  1758. 5       0       0       0       2
  1759. 6       0       0       0       2
  1760. .fi
  1761. where exactly one tab-character separates the columns.
  1762. .LP
  1763. The command 
  1764. .I invert < data
  1765. yields 
  1766. .nf
  1767. col     x       y 
  1768. ---     -       -
  1769. 1       1       2
  1770. 1       1       3
  1771. 2       3       4
  1772. 2       4       5
  1773. 2       4       6
  1774. .fi
  1775. on the standard output.
  1776. .SH "SEE ALSO"
  1777. .BR reldb(1),\ matrix(1).
  1778. .SH BUGS
  1779. .LP
  1780. .I Invert 
  1781. uses awk to do its work. This makes for easy programming, but at a cost
  1782. in efficiency. Usually, tables are small and this is not a problem.
  1783. \Rogue\Monster\
  1784. else
  1785.   echo "will not over write ./doc/invert.1"
  1786. fi
  1787. if `test ! -s ./doc/number.1`
  1788. then
  1789. echo "writting ./doc/number.1"
  1790. cat > ./doc/number.1 << '\Rogue\Monster\'
  1791. .\" man-page for number(1).
  1792. .TH NUMBER 1 "1. April 1989"
  1793. .SH NAME
  1794. number - add a column with sequential line number.
  1795. .SH SYNOPSIS
  1796. .B number
  1797. [
  1798. .I < data
  1799. ]
  1800. .SH DESCRIPTION
  1801. .B Number
  1802. adds a columns to a
  1803. .I reldb
  1804. table and inserts the line number into the column.
  1805. This is essentially the same as 
  1806. .I nl(1),
  1807. but the input and output are 
  1808. .I reldb
  1809. tables.
  1810. .SH "SEE ALSO"
  1811. .BR reldb(1),\ nl(1).
  1812. .SH BUGS
  1813. .LP 
  1814. No bugs are known.
  1815. \Rogue\Monster\
  1816. else
  1817.   echo "will not over write ./doc/number.1"
  1818. fi
  1819. if `test ! -s ./doc/check.1`
  1820. then
  1821. echo "writting ./doc/check.1"
  1822. cat > ./doc/check.1 << '\Rogue\Monster\'
  1823. .\" man-page for check(1).
  1824. .TH check 1 "19. April 1989"
  1825. .SH NAME
  1826. check - check sanity of reldb table(s).
  1827. .SH SYNOPSIS
  1828. .B check
  1829. .I data-files
  1830. .SH DESCRIPTION
  1831. .B check
  1832. reads the named
  1833. .I reldb
  1834. tables and checks them for sanity, i.e. for the number of tab characters
  1835. per line. 
  1836. .SH "SEE ALSO"
  1837. .BR reldb(1).
  1838. .SH BUGS
  1839. .LP 
  1840. No bugs are known.
  1841. \Rogue\Monster\
  1842. else
  1843.   echo "will not over write ./doc/check.1"
  1844. fi
  1845. if `test ! -s ./doc/recode.1`
  1846. then
  1847. echo "writting ./doc/recode.1"
  1848. cat > ./doc/recode.1 << '\Rogue\Monster\'
  1849. .\" Man page for recode(1)
  1850. .TH RECODE 1 "1. April 1989"
  1851. .SH NAME
  1852. recode - recode a column in a table
  1853. .SH SYNOPSIS
  1854. .B recode
  1855. .I codefile
  1856. [
  1857. .I <\ datafile
  1858. ]
  1859. [
  1860. .I >\ result
  1861. ]
  1862. .SH DESCRIPTION
  1863. .LP
  1864. .B Recode
  1865. reads the recoding scheme
  1866. for
  1867. .I codefile
  1868. and applies it to the first column in the 
  1869. .I datafile.
  1870. .LP
  1871. The
  1872. .I codefile
  1873. contains two columns, 
  1874. .I oldcode
  1875. and
  1876. .I newcode
  1877. (in that order).
  1878. .LP
  1879. The
  1880. .I datafile
  1881. is assumed to contain the old code as the first column.
  1882. .LP
  1883. The output consists of a new column, of the same name as the
  1884. .I newcode
  1885. column in 
  1886. .I codefile,
  1887. and then the columns of the 
  1888. .I datafile.
  1889. .SH EXAMPLE
  1890. .LP
  1891. Suppose the file 
  1892. .I recode.data
  1893. contains the lines:
  1894. .nf
  1895. ex1    w    y    z    v    u    extra
  1896. ---    -    -    -    -    -    -----
  1897. 25    0    9    2    3    4    -3
  1898. 4    0    2    2    3    4    -2
  1899. 5    0    3    4    5    6    -3
  1900. 5    2    3    4    6    7    -4
  1901. 9    2    5    6    7    10    -3
  1902. 9    2    5    6    120    8    -116
  1903. 9    23    5    6    7    8    16
  1904. 25    0    9    2    3    4    -3
  1905. 25    2    9    2    5    6    -3
  1906. .fi
  1907. And the code file
  1908. .I recode.codes
  1909. contains :
  1910. .nf
  1911. ex1    new
  1912. ---    ---
  1913. 1    20
  1914. 2    21
  1915. 3    22
  1916. 4    23
  1917. 5    24
  1918. 9    25
  1919. 25    0
  1920. .fi
  1921. The following is the output from the command
  1922. .I recode\ recode.codes\ <\ recode.data
  1923. .nf
  1924. new    ex1    w    y    z    v    u    extra
  1925. ---    ---    -    -    -    -    -    -----
  1926. 0    25    0    9    2    3    4    -3
  1927. 23    4    0    2    2    3    4    -2
  1928. 24    5    0    3    4    5    6    -3
  1929. 24    5    2    3    4    6    7    -4
  1930. 25    9    2    5    6    7    10    -3
  1931. 25    9    2    5    6    120    8    -116
  1932. 25    9    23    5    6    7    8    16
  1933. 0    25    0    9    2    3    4    -3
  1934. 0    25    2    9    2    5    6    -3
  1935. .fi
  1936. .SH BUGS
  1937. .LP
  1938. There is a built-in limit on the magnitude of the old codes, as these are
  1939. read into a hard-coded vector.
  1940. \Rogue\Monster\
  1941. else
  1942.   echo "will not over write ./doc/recode.1"
  1943. fi
  1944. echo "Finished archive 3 of 3"
  1945. exit
  1946.  
  1947.