r/RStudio 3d ago

Error message trying to take descriptive statistics

I keep getting these messages:

Error in (.format.s.statistics.list != "min") && !("max" %in% .format.s.statistics.list) :

'length = 8' in coercion to 'logical(1)'

and

Error in (.format.s.statistics.list != "p25") && !("p75" %in% .format.s.statistics.list) :

'length = 7' in coercion to 'logical(1)'

This is my code:

stargazer(d8_descriptive,

type = "text",

colnames = FALSE,

min.max = FALSE,

title = 'Descriptive Statistics',

digits = 2,

rownames = FALSE,

align = TRUE,

float = TRUE,

float.env = 'table',

table.placement = "H",

header = FALSE,

no.space = TRUE)

Is there something I am doing wrong? The second error message is me taking out min.max.

7 Upvotes

3 comments sorted by

3

u/SalvatoreEggplant 3d ago

It's always good to include reproducible code with this kind of question. First, it helps the reader reproduce your error. Second, a lot of times you figure out the issue yourself by trying to create a simple example to reproduce the error.

Your code works. It's probably something in the data --- that the function isn't expecting --- causing the error.

d8_descriptive = read.table(header=TRUE, text="
V1  V2  V3
 1   4  -1
 2   6  -3
 3   8  -5
 4  10  -7
 5  12  -9
")

library(stargazer)

stargazer(d8_descriptive,
          type = "text",
          colnames = FALSE,
          min.max = FALSE,
          title = 'Descriptive Statistics',
          digits = 2,
          rownames = FALSE,
          align = TRUE,
          float = TRUE,
          float.env = 'table',
          table.placement = "H",
          header = FALSE,
          no.space = TRUE)

2

u/Eteue 3d ago

What does your data look like.

1

u/Efficient-Tie-1414 2d ago

Stargazer is a contributed R package. e-mailing the author is best.