tokenize-methods: Tokenize R Code

tokenize_fileR 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")

sourcetools documentation built on Feb. 16, 2023, 5:09 p.m.