0

When using dfsummary() from the summarytools package on a factor vector, the values in freqs column have random backslashes at the start. Please see this output image.

This is the code:

x <- factor(c("Tertiary_pattern_3", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_4", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_4", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_4", "Tertiary_pattern_2", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_4", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_5", "Tertiary_pattern_4", "Tertiary_pattern_5"))
print(kable(dfSummary(x,
            graph.col    = FALSE,
            style        = "grid",
            plain.ascii  = FALSE
            ),
            method = "render") %>%
      kable_styling('bordered', bootstrap_options = c("striped", "hover", "condensed")),'\n\n')

The input to dfsummary is a factor vector. The above image is just one example, I am facing this issue in almost every case in which a factor vector is involved. However, I don't face this issue when the vector is numeric or date. I am using this chunk of code in a r markdown file and knitting to html.

Output image for the exact above code

  • Can you provide your dataset so we can reproduce this error? See here: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – jrcalabrese Jun 29 '23 at 12:04
  • @jrcalabrese I have added a small subset of my data and attached an image of output for it – Shardul Nazirkar Jun 29 '23 at 20:01
  • Note that your example also depends on the `kableExtra` package. In addition, when I ran it, I got an error message `Error in pryr::where(obj_name) : length(name) == 1 is not TRUE`, so my plot output is not the same as what you've shared. – C. Murtaugh Jul 01 '23 at 18:58

0 Answers0