Skip to contents

Turns cell formatting into annotations for values in the target variable.

Usage

annotate_mf(xlfilepath, orig, new)

Arguments

xlfilepath

Path to a single-sheet spreadsheet file (xls or xlsx).

orig

Target variable to annotate formatting in.

new

Name of new variable with cell formatting pasted as a string.

Value

A tibble with a new column in which the meaningful formatting is embedded as text.

Details

Seven popular approaches for meaningful formatting (bold, colored text, italic, strikethrough, underline, double underline, and cell highlighting) are hardcoded in the function. sheets, skip, and range arguments for spreadsheet input are not supported. The hex8 code of the fill color used for text color and cell highlighting is also appended in the output. Ensure the data in the spreadsheet are rectangular before running; this includes blank but formatted cells beyond the data rectangle.

Examples

example_spreadsheet <- system.file("extdata/dog_test.xlsx", package = "unheadr")
annotate_mf(example_spreadsheet, orig = Task, new = Task_annotated)
#> # A tibble: 11 × 3
#>    Task                                               Task_annotated       Score
#>    <chr>                                              <chr>                <dbl>
#>  1 Outdoor activities                                 (bold, highlight-FF…  7.67
#>  2 Walks on a loose leash without pulling             Walks on a loose le…  7   
#>  3 Walks without chasing bicycles, animals, etc.      Walks without chasi…  6   
#>  4 Greets friends and strangers without jumping       Greets friends and … 10   
#>  5 Home behavior                                      (bold, highlight-FF…  8.5 
#>  6 Moves location when directed without growling      Moves location when…  9   
#>  7 Does not rush through doorways                     Does not rush throu…  8   
#>  8 General social skills and obedience                (bold, highlight-FF…  7   
#>  9 Can play or interact appropriately with other dogs Can play or interac…  7   
#> 10 Can be groomed or handled without squirming        Can be groomed or h…  8   
#> 11 Stops barking on command                           Stops barking on co…  6