read.tfl {zipfR} | R Documentation |
read.tfl
loads type frequency list from .tfl
file
write.tfl
saves type frequency list object in .tfl
file
read.tfl(file) write.tfl(tfl, file)
file |
character string specifying the pathname of a disk file. See section "Format" for a description of the required file format |
tfl |
a type frequency list, i.e.\ an object of class tfl |
A TAB-delimited text file with column headers but no row names
(suitable for reading with read.delim
), containing the
following columns:
f
k
type
These columns may appear in any order in the text file. Only the
f
column is mandatory and all unrecognized columns will be
silently ignored.
The .tfl
file format stores neither the values of N
and
V
nor the range of type frequencies explicitly. Therefore,
incomplete type frequency lists cannot be fully reconstructed from
disk files (and will not even be recognized as such). An attempt to
save such a list will trigger a corresponding warning.
read.tfl
returns an object of class tfl
(see the
tfl
manpage for details)
See the tfl
manpage for details on tfl
objects. See read.spc
and read.vgc
for
import/export of other data structures.
## Not run: ## examples will not be run during package compilation ## since they would require accessing and writing to ## external files ## load Brown tfl and write it to external file data(Brown.tfl) write.tfl(Brown.tfl,"brown.tfl") ## now brown.tfl is external file with fields ## k (an id), f (frequency), type (word) ## read it back in New.tfl <- read.tfl("brown.tfl") ## same as Brown.tfl summary(New.tfl) summary(Brown.tfl) print(New.tfl) print(Brown.tfl) head(New.tfl) head(Brown.tfl) ## suppose you have a text file with a ## frequency list, one f per line, e.g.: ## f ## 14 ## 12 ## 31 ## ... ## you can import this with read.tfl MyData.tfl <- read.tfl("mylist.txt") summary(MyData.tfl) print(MyData.tfl) # ids in column k added by zipfR ## from this you can generate a spectrum with tfl2spc MyData.spc <- tfl2spc(MyData.tfl) summary(MyData.spc) ## End(Not run)