stargazer error "length of NULL cannot be changed"
Asked Answered
S

1

6

I'm trying to produce a proper table with stargazer in markdown. The linear model code is as follows:

k <- lm(mean_p ~ P*MA, data=d)

Calling the following stargazer-function however does not work, produces the error

length of NULL cannot be changed

and only produces html-code.

stargazer(k,type="html")

This is the Output of the dput(head(d))-call:

structure(list(
age = c(15.1666666666667, 14.9166666666667, 
13.3333333333333, 12.0833333333333, 10.9166666666667, 13.75), 
gender = c("girls", "girls", "boys", "girls", "boys", "girls"), 
MA = c("NM", "NM", "NM", "NM", "NM", "NM"), 
AFC = c(0, 0, 0, 0, 0, 0), 
test_k_1 = c(3, 3, 3, 3, 0, 0), test_k_2 = c(6, 3, 6, 6, 3, 3), 
test_k_3 = c(9, 0, 6, 3, 0, 0), test_k_4 = c(3, 3, 9, 6, 0, 0), 
test_u_1 = c(3, 3, 6, 3, 0, 0), test_u_2 = c(6, 3, 0, 0, 0, 0), 
test_u_3 = c(9, 0, 3, 0, 0, 0), test_u_4 = c(3,0, 0, 0, 0, 0), 
test_n_3 = c(6, 3, 6, 0, 0, 3), test_n_4 = c(3,0, 9, 0, 0, 3), 
k = c(6, 2, 7, 5, 1, 1), b = c(6,1, 1, 0, 0, 0), 
d = c(6, 2, 8, 1, 0, 3), 
s = c(6,1.66666666666667,5.33333333333333, 2, 0.333333333333333,    1.33333333333333), 
mean_p = c(6, 1.66666666666667, 5.33333333333333,2, 0.333333333333333, 1.33333333333333), 
zc = c(-0.669549727292442, 
    -0.669549727292442, -0.669549727292442, -0.669549727292442, 
    -0.669549727292442, -0.669549727292442), 
znum = c(-0.643217641381636, -0.643217641381636, -0.643217641381636, -0.643217641381636, -0.643217641381636, -0.643217641381636), 
zse = c(-0.708845108492594, -0.708845108492594, -0.708845108492594, -0.708845108492594, -0.708845108492594, -0.708845108492594), 
m = c(-0.669549727292442,-0.669549727292442, -0.669549727292442, -0.669549727292442, -0.669549727292442, -0.669549727292442), 
P = c(-0.416305415592902, -0.442252258358532, -0.499214827082544, -0.699404516110036, -0.39383368539238, -0.702020755840638)), 
row.names = c(186L,187L, 195L, 197L, 199L, 200L), class = "data.frame")

Does anybody know how to solve that problem? Thanks in advance for any hints.

Seriatim answered 9/8, 2019 at 12:8 Comment(4)
Welcome to Stack Overflow! Help others help you by providing a minimal reproducible example. In particular we can't reproduce your problem without (at least a subset of) your data. You can provide it by editing your question to include the output of dput(d) or dput(head(d))Feeley
you don't have variables x, y, z in your actual data: what was the actual model you ran?Zagreb
Sorry, now the model vars are correct...Seriatim
1) Your model cannot be estimated with your data since MA = NM for all observations. 2) if I relabeled MA on one of the observations to something else, I was not able to replicate your issue. Could you include the output of your sessionInfo()? Which version of Stargazer are you using?Embonpoint
J
0

For me, this problem disappeared when I updated tidyverse, as described here: https://tidyverse.tidyverse.org/reference/tidyverse_update.html

Jenifer answered 10/8, 2020 at 11:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.