
Function reference
-
autoharp-packageautoharp - autoharp: Semi-Automatic Grading of R and Rmd Scripts
Core Grading Functions
The primary functions you need to set up and run the grading workflow. Start with populate_soln_env() to prepare the solution environment, then use render_one() to grade individual student scripts.
-
populate_soln_env() - Returns solution environment and test code from template.
-
render_one() - Run a single Rmd file through autoharp.
-
log_summary() - Generate a dataframe from the log file.
TreeHarp S4 Class
The TreeHarp S4 class represents any R expression as a rooted, directed tree using Breadth-First Search ordering. This enables powerful static code analysis beyond simple pattern matching.
-
TreeHarp()TreeHarp()length(<TreeHarp>)show(<TreeHarp>)names(<TreeHarp>) - An R expression as a tree.
-
lang_2_tree() - Convert language object to tree.
-
to_BFS() - Function to rearrage nodes in BFS
-
subtree_at() - Extract a sub-tree.
-
generate_all_subtrees() - Generate all subtrees from a tree.
-
carve_subtree() - Carve out branches to form a new tree.
-
is_subtree_rooted_at() - Checks if a tree is rooted at a node of another tree.
-
path_to_root() - Extract a path from node to root.
-
get_recursive_index() - Obtain an index to extract out a sub-call
-
get_parent_call_id() - Get Node Id of Parent Call
-
join_treeharps() - Root a list of trees.
ForestHarp — Working with Script Files
Functions for converting entire R/Rmd/qmd scripts into collections of TreeHarp objects and applying analyses across them.
-
rmd_to_forestharp() - Convert to TreeHarp objects
-
fapply() - Apply a function to a forest of trees.
-
count_self_fn()count_lam_fn()count_fn_call()extract_fn_call()extract_formal_args()extract_assigned_objects()extract_actual_args()count_num_lines_for_loop()detect_growing()detect_for_in_fn_def()count_fn_in_fn()detect_fn_call_in_for()extract_self_fn()detect_fn_arg()detect_nested_for() - Forestharp helpers
-
pipe_can_improve_this() - Identify if use of pipe operator can improve a code section
-
apply_can_improve_this() - Identifies if an apply function can improve the code
-
only_actual_args_differ() - Checks if two expressions differ only in terms of actual arguments
Checking & Assessment Functions
Functions for checking the correctness of student outputs, validating R Markdown structure, measuring runtime performance, and counting code style lint violations.
-
check_correctness() - Check correctness of student solution rmd.
-
check_rmd() - Check if a File is Rmd
-
check_runtime() - Calculate Run-time Statistics
-
count_lints_one() - File lint counter
-
count_lints_all() - Lint counter
Script Utilities
Utility functions for extracting content from scripts, managing environments, and working with file paths.
-
extract_chunks() - Extract chunks that match a pattern.
-
extract_non_chunks() - Extract non-chunks from an Rmd file.
-
extract_section_text() - Extract section text from Rmd
-
get_libraries() - Extracts the Packages Used in An Rmd File.
-
generate_thumbnails() - Generate a html of thumbnails
-
env_size() - Calculates the Total Memory Used
-
rmd_to_token_count() - Count tokens in R/Rmd
-
render_prechecks() - Conducts checks before rendering file
-
reset_path() - Reset search path of current R session
-
clean_dir() - Removes md Files when no HTML Present
-
replace_sp_chars_filename() - Replace Special Characters in File Name
-
copy_e2e() - Copy an object from one env to another.
TreeHarp Accessors & Methods
S4 generic methods and accessor functions for working with individual TreeHarp objects — inspecting their structure, navigating the tree, and plotting.
-
get_adj_list() - Generic for Getting Adjacency List
-
get_node_types() - Generic for Getting Node Types
-
get_parent_id() - Generic for Getting Parent Node Id.
-
get_child_ids() - Generic for Getting Child Node Ids
-
get_levels() - Obtains the node levels from a tree.
-
plot(<TreeHarp>) - TreeHarp Plotting TreeHarp Objects
-
as.matrix - TreeHarp Cast a TreeHarp to Matrix.
TreeHarp Internal Helpers
Lower-level helper functions used internally by the TreeHarp system. These are exported for advanced users building custom analyses.
-
adj_list_2_matrix() - Convert adjacency list to a matrix
-
matrix_2_adj_list() - Convert adjacency matrix to a list.
-
prune_depth() - Prune a tree up to a specified depth.
-
keep_branches() - Keep only branches specified by node numbers
-
find_branch_num() - Find the branch that leads from one node to another.
-
rbind_to_nodes_info() - Update node information.
-
is_connected() - Checks if a graph is connected.
-
is_cyclic_r() - Checks if a graph contains any cycles.
-
update_adj_list() - Update adjacency list.
-
get_next_subtree() - Generate the next sub-tree.
-
get_next_depth_id() - Get the id and depth of a child node.
-
tree_sim() - Compute tree similarity
-
jaccard_treeharp() - Computes Jaccard Index
-
carve_mst() - Carve a Minimal Spanning Tree Out
-
K2() - Compute tree similarity
-
get_child_ids2() - Get the children node ids
-
get_parent_id2() - Get the parent node id