Using fmt_markdown()
on a factor prints the numeric factor level when the output format is HTML
#1882
Closed
2 tasks done
Prework
Description
When
fmt_markdown()
is used on a column that contains factor data, it prints the numeric levels of the factor and not their text labels. This only happens when outputting to HTML, and not with other output formats like latex. I believe this is because themd()
function, which is used for HTML output, replaces the class of the vector, meaning a factor would lose its factor class and be assigned a new class over its underlying integer type.I believe this could be fixed by having
md()
first convert its input to character, then reclass it. I'd be happy to submit a PR if it would be helpful.Reproducible example
Created on 2024-09-17 with reprex v2.1.0
Expected result
The HTML output should have included the character label for
x
("TEST") rather than its numeric level (1). The latex output exhibits the expected behavior.Session info
Created on 2024-09-17 with reprex v2.1.0
The text was updated successfully, but these errors were encountered: