Type: Package
Title: The Ultimate Helper for Clumsy Fingers
Version: 0.2.0
Description: Automatically suggests a correction when a typo occurs.
License: GPL-3
URL: https://thinkr-open.github.io/fcuk/, https://github.com/ThinkR-open/fcuk
BugReports: https://github.com/ThinkR-open/fcuk/issues
Depends: R (≥ 4.1.0)
Imports: cli, clisymbols, crayon, rstudioapi, stringdist, utils
Suggests: knitr, rmarkdown, testthat (≥ 3.0.0)
VignetteBuilder: knitr
ByteCompile: true
Config/testthat/edition: 3
Encoding: UTF-8
RoxygenNote: 7.3.3
NeedsCompilation: no
Packaged: 2026-02-25 14:00:35 UTC; PC
Author: Vincent Guyader ORCID iD [cre, aut], ThinkR [cph]
Maintainer: Vincent Guyader <vincent@thinkr.fr>
Repository: CRAN
Date/Publication: 2026-02-26 10:20:07 UTC

fcuk: The Ultimate Helper for Clumsy Fingers

Description

Automatically suggests a correction when a typo occurs.

The fcuk package automatically suggests corrections when a typo occurs in R code. It intercepts error messages and provides helpful suggestions based on string distance algorithms.

Main Features

Getting Started

The package is automatically activated when loaded with 'library(fcuk)'. When an error occurs, fcuk will suggest corrections. Use '.+1' to apply the first suggestion, or '.+2' for the second.

Functions

Author(s)

Maintainer: Vincent Guyader vincent@thinkr.fr (ORCID)

Other contributors:

See Also

Useful links:

Useful links:


Rerun with correction

Description

Use the '+' operator with the '.' object to apply a correction.

Usage

## S3 method for class 'fcuk'
x + y

Arguments

x

Blank object of class fcuk.

y

An integer corresponding to the position of the proposal to be reused.

Value

Invisibly returns a blank object.

Examples

## Not run: 
view(iris) # error
. + 1 # returns View(iris)

## End(Not run)

Placeholder object for rerun operator

Description

Use '.+1' or '.+2' to rerun the last command with a suggested correction.

Usage

.

Format

An object of class fcuk of length 1.

Examples

## Not run: 
view(iris) # error
. + 1 # returns View(iris)

## End(Not run)

Add library(fcuk) to the .Rprofile file

Description

After calling this function, fcuk will be launched everytime you launch your current R project (or any project if you use option 'global = TRUE').

Usage

add_fcuk_to_rprofile(global = TRUE)

Arguments

global

Whether to add it to the global .Rprofile ('TRUE', the default) or just to the .Rprofile file of your current project ('FALSE').

Value

Invisibly returns 'NULL'.

Examples

## Not run: 
fcuk::add_fcuk_to_rprofile()

## End(Not run)

Capture and parse an error message

Description

Extract the object or function name from an error message.

Usage

catch_error(sentence = geterrmessage())

Arguments

sentence

An error message to parse. Defaults to the last error message.

Value

A character vector with extracted names, or 'character(0)' if no match is found.

Examples

catch_error()
catch_error("Error: object 'iri' not found\n")
catch_error("Error: object 'view' not found\n")

Error Analysis

Description

Analyse the last error message and suggest corrections.

Usage

error_analysis(asked_objet = catch_error(), n = 2)

Arguments

asked_objet

The name to analyse. Defaults to extracting from last error.

n

Number of names to suggest (default: 2).

Value

Invisibly returns a string with the suggestions, or 'NULL' if no error could be parsed.

Examples

fcuk::error_analysis() # last error is analysed
fcuk::error_analysis("view")
fcuk::error_analysis("iri")

Find closest object names

Description

Analyse a typo and suggests the closest names.

Usage

error_correction_propostion(asked_objet, method = "jaccard", n = 2)

Arguments

asked_objet

The R name producing an error.

method

Method for distance calculation. The default is "jaccard", see [stringdist::stringdist-metrics].

n

Number of corrections to suggest (default: 2).

Value

A character vector with the closest neighbors, or 'character(0)' if no valid input is provided.

Examples

error_correction_propostion("iri")
error_correction_propostion("view")

Extract the name of all objects loaded in the R environments

Description

Fetch the name of all objects loaded in the environments (functions, values, data...)

Usage

get_all_objects_from_r(use_cache = TRUE)

get_all_objets_from_r(use_cache = TRUE)

Arguments

use_cache

Logical. Use cached results if available (default: TRUE). Cache is invalidated when environment changes.

Value

A character vector with the names of all objects contained in the environments

Examples

get_all_objects_from_r()

Return corrected instruction

Description

Get the corrected command at position 'n'.

Usage

get_last(n = 1)

Arguments

n

Position of the correction (default: 1).

Value

A character string with the corrected command, or 'NA' if unavailable.

Examples

get_last()

Init error tracker

Description

After launching this function, every error message will be analysed. This function is called when loading the package.

Usage

init_error_tracker()

Value

Invisibly returns 'NULL'.

Examples

getOption("error")
fcuk::init_error_tracker()
getOption("error")

Remove error tracker

Description

After launching this function, the errors will no longer be analysed.

Usage

remove_error_tracker()

Value

Invisibly returns 'NULL'.

Examples

getOption("error")
fcuk::remove_error_tracker()
getOption("error")