Package 'loc'

Title: Count Lines of Code
Description: Use the 'Tokei' Rust crate to count lines of code in files and folders. It supports dozens of different languages, and also provides statistics on blank lines and comments.
Authors: Etienne Bacher [aut, cre, cph]
Maintainer: Etienne Bacher <[email protected]>
License: MIT + file LICENSE
Version: 0.0.2
Built: 2026-10-07 08:56:11 UTC
Source: https://github.com/etiennebacher/loc

Help Index


Count lines of code

Description

Count lines of code

Usage

count_loc(
  paths = ".",
  excluded = NULL,
  include_hidden = FALSE,
  languages = "R"
)

Arguments

paths

Paths to include.

excluded

Paths to exclude.

include_hidden

Count hidden files and directories? Default is FALSE.

languages

Languages to consider. See the list here: https:#github.com/XAMPPRocky/tokei?tab=readme-ov-file#supported-languages.

Value

A data.frame with 4 columns: number of blank lines, comments, code, and whether the count is accurate.

Examples

tmp <- tempfile(fileext = ".R")
cat("
library(loc)
# This is a function
foo <- function(x) {
  x + 1
}

", file = tmp)
count_loc(tmp)