stats
importdata
Read Statistical Data from a File
Calling Sequence
Parameters
Description
Examples
stats[importdata](filename, n)
importdata(filename, n)
filename
-
name of the file to be read
n
(optional, default=1) number of streams into which to split the file data
Important: The stats package has been deprecated. Use the superseding package Statistics instead.
The function importdata of the stats package reads statistical data from a file.
The data in the file are just a sequence of numbers, separated by spaces or the end of line. They will be processed by a sscanf(..., `%f`).
The character # introduces a comment that ends at the end of that line.
Missing data are represented in the data file by the * character. It will be converted to the keyword missing.
If the number of streams, which is indicated by the parameter n, is one, the data in the file given by filename are returned as an expression sequence. If the number of streams is greater than one then the data in the file are returned as an expression sequence of n lists. The first item in the file goes into the first list, the second item goes into the second list, and so on, until there is an item in each list. The next item in the file then goes at the end of the first list, and so on until the whole file is imported.
More sophisticated data files can be read using readline and sscanf. The function {readdata} is very similar to stats[importdata].
The command with(stats,importdata) allows the use of the abbreviated form of this command.
with⁡stats:
T≔importdata⁡datafile,2
where the datafile could contain the following ------------------------
| # this is a comment
| 2 3
| 4 5
| 6 * # one missing data
| # another comment
------------------------
At the end T will be
T_received≔2.0,4.0,6.0,3.0,5.0,missing
See Also
readdata
readline
sscanf
Statistics
stats(deprecated)[data]
transform(deprecated)[split]
Download Help Document