Learn R Programming

Wmisc (version 0.3.4)

readTokens: Read the remaining tokens from a Tokenizer up to the end of the underlying file.

Description

A comfortable way to read all remaining tokens from a file open through a tokenizer..

A comfortable way to read all lines from a file. Syntactic sugar for readTokens(Tokenizer$new(filename),delims=c(10L,13L)).

Usage

# readTokens(mytok)
# readTokens(Tokenizer$new("myfile.txt"),c("0x20L"))

# readlines("myfile.txt")

Arguments

tok

The tokenizer from which to read.

delims

The delimiters to use for the remaining tokens.

filename

The file to read.

Value

A vector of strings representing the read tokens.

A vector of strings representing the lines of the file.

Examples

Run this code
# NOT RUN {
tok<-Tokenizer$new("myfile.txt")           # create a tokenizer
tok$nextToken()                            # read some tokens
readTokens(tok,as.integer(charToRaw("+"))) # read the rest of the file, now delimited by "+"
readTokens(Tokenizer$new("myfile.txt"))    # read all tokens
readTokens("myfile.txt")                   # same as above, syntactic sugar
# }
# NOT RUN {
readlines("myfile.txt")
# }

Run the code above in your browser using DataLab