Learn R Programming

quickcode (version 1.0.6)

extract_comment: Extract all comments or functions from a file

Description

Vectorize all comments from the file

Usage

extract_comment(file)

remove_content_in_quotes(line)

remove_comment(line)

clean_file(file, output_file)

get_func_def(file)

Value

vector of all comments within a file

Arguments

file

file to parse

line

string vector to remove contents within quotes or comments

output_file

file path to write the output of the new file

Examples

Run this code
if (FALSE) {
ex_file1 <- "path/file1.R"
# get all comments
cmmts <- extract_comment(ex_file1)
cmmts
}

if (FALSE) {
# Ex to clean out comments from file
file_path <- ".testR"
output_file_path <- ".cleaned_script.R"
clean_file(file_path, output_file_path)
}

# example code

if (FALSE) {
# Ex to get all defined functions
# within a file
file_path <- ".testR"
get_func_def(file_path)
}

Run the code above in your browser using DataLab