as.data.frame.nonogram: as.data.frame.nonogram

View source: R/as.data.frame.nonogram.R

as.data.frame.nonogramR Documentation

as.data.frame.nonogram

Description

Extracts the solution of a solved nonogram into a tidy data.frame. Used primarily for tidying the data prior to plotting.

Usage

## S3 method for class 'nonogram'
as.data.frame(nonogram, with_solution = TRUE)

Arguments

nonogram

An object of class nonogram.

with_solution

TRUE (default) or FALSE. Whether the data.frame should contain the nonogram solution.

Details

If with_solution = FALSE, the function will return a data.frame with the appropriate column and row indices, but the value column will contain only 0s. This is only really useful when plotting a nonogram without its solution. If with_solution = TRUE and the nonogram does not have a solution, the function will throw an error.

Value

A data.frame with 3 columns:

  • value: If with_solution = TRUE, the solution for each position. All 0 otherwise.

  • column: The column index where 1 = the leftmost column.

  • row: The row index where 1 = the top row.

Examples

f <- examples[[1]] |> solve(verbose = FALSE)
as.data.frame(f)
as.data.frame(f, with_solution = FALSE)

hrj21/nonogram documentation built on April 6, 2024, 1:14 a.m.