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

Description Usage Arguments Value Examples

View source: R/Tokenizer.R

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

1
2
3
4
# 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## 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

## End(Not run)
## Not run: 
readlines("myfile.txt")

## End(Not run)

Example output

Warning messages:
1: In normalizePath(as.character(filename)) :
  path[1]="myfile.txt": No such file or directory
2: In .subset2(public_bind_env, "initialize")(...) :
  No file at file location 'myfile.txt'. Tokenizer will always return NA.
[1] NA
character(0)
character(0)
Warning messages:
1: In normalizePath(as.character(filename)) :
  path[1]="myfile.txt": No such file or directory
2: In .subset2(public_bind_env, "initialize")(...) :
  No file at file location 'myfile.txt'. Tokenizer will always return NA.
character(0)
Warning messages:
1: In normalizePath(as.character(filename)) :
  path[1]="myfile.txt": No such file or directory
2: In .subset2(public_bind_env, "initialize")(...) :
  No file at file location 'myfile.txt'. Tokenizer will always return NA.
character(0)
Warning messages:
1: In normalizePath(as.character(filename)) :
  path[1]="myfile.txt": No such file or directory
2: In .subset2(public_bind_env, "initialize")(...) :
  No file at file location 'myfile.txt'. Tokenizer will always return NA.

Wmisc documentation built on Jan. 14, 2018, 1:04 a.m.