# NOT RUN {
# }
# 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)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab