R: Tokenize R Code

tokenize_file {sourcetools} | R Documentation

## Tokenize R Code

### Description

Tools for tokenizing R code.

### Usage

    tokenize_file(path)

    tokenize_string(string)

    tokenize(file = "", text = NULL)

### Arguments

`file, path` | A file path.
`text, string` | R code as a character vector of length one.

### Value

A `data.frame` with the following columns:

`value` | The token's contents, as a string.
`row` | The row where the token is located.
`column` | The column where the token is located.
`type` | The token type, as a string.

### Note

Line numbers are determined by existence of the `\n` line feed character, under the assumption that code being tokenized will use either `\n` to indicate newlines (as on modern Unix systems), or `\r\n` as on Windows.

### Examples

    tokenize_string("x <- 1 + 2")

[Package sourcetools version 0.1.6 Index]