Not sure why it's not working for you. I tried a similar operation and even made a variable with spaces in the name in the mtcars
data and it worked. Does this code work for you?
library(summarytools)
data(mtcars)
mtcars <- mtcars %>% rename("miles per gallon" = mpg)
stby(data = mtcars[,c("miles per gallon", "hp", "cyl")],
INDICES = mtcars$cyl,
FUN = descr,
stats= "common",
transpose=TRUE,
style = "rmarkdown",
plain.ascii = FALSE)
Output
### Descriptive Statistics
#### mtcars
**Group:** cyl = 4
**N:** 11
| | Mean | Std.Dev | Min | Median | Max | N.Valid | Pct.Valid |
|---------------------:|------:|--------:|------:|-------:|-------:|--------:|----------:|
| **cyl** | 4.00 | 0.00 | 4.00 | 4.00 | 4.00 | 11.00 | 100.00 |
| **hp** | 82.64 | 20.93 | 52.00 | 91.00 | 113.00 | 11.00 | 100.00 |
| **miles per gallon** | 26.66 | 4.51 | 21.40 | 26.00 | 33.90 | 11.00 | 100.00 |
**Group:** cyl = 6
**N:** 7
| | Mean | Std.Dev | Min | Median | Max | N.Valid | Pct.Valid |
|---------------------:|-------:|--------:|-------:|-------:|-------:|--------:|----------:|
| **cyl** | 6.00 | 0.00 | 6.00 | 6.00 | 6.00 | 7.00 | 100.00 |
| **hp** | 122.29 | 24.26 | 105.00 | 110.00 | 175.00 | 7.00 | 100.00 |
| **miles per gallon** | 19.74 | 1.45 | 17.80 | 19.70 | 21.40 | 7.00 | 100.00 |
**Group:** cyl = 8
**N:** 14
| | Mean | Std.Dev | Min | Median | Max | N.Valid | Pct.Valid |
|---------------------:|-------:|--------:|-------:|-------:|-------:|--------:|----------:|
| **cyl** | 8.00 | 0.00 | 8.00 | 8.00 | 8.00 | 14.00 | 100.00 |
| **hp** | 209.21 | 50.98 | 150.00 | 192.50 | 335.00 | 14.00 | 100.00 |
| **miles per gallon** | 15.10 | 2.56 | 10.40 | 15.20 | 19.20 | 14.00 | 100.00 |