Hello, I don't have the slightest clue what stargazer is supposed to be doing, but it seems as though it's trying to create names for the ... list using: object.names.string <- deparse(substitute(list(...))) It makes an error in assuming that the return value of deparse will be a character string. For stargazer(res), object.names.string becomes: "list(res)" while for do.call(stargazer, list(res)), object.names.string becomes: [1] "list(structure(list(coefficients = c(`(Intercept)` 6.41594246095523, " [2] "UrbanPop = 0.0209346588197249), residuals = c(Alabama 5.56984732750071, " [3] "Alaska = 2.57919391569797, Arizona = 0.009284833466778, Arkansas = 1.33732459805853, " [4] "California = 0.679003586449805, Colorado = -0.148845848893771, " [5] "Connecticut = -4.72791119007405, Delaware = -2.02323789597542, " [6] "Florida = 7.30928483346678, Georgia = 9.72797800986128, Hawaii -2.8535191429924, " [7] "Idaho = -4.94641403722037, Illinois = 2.2464808570076, Indiana -0.576695284237348, " [8] "Iowa = -5.40921801367955, Kansas = -1.79762994305707, Kentucky 2.19545528041907, " [9] "Louisiana = 7.60237005694293, Maine = -5.3836100607612, Maryland = 3.4814353981232, " [ reached getOption("max.print") -- omitted 110 entries ] perhaps the package maintainer could change the line from: object.names.string <- deparse(substitute(list(...))) to: object.names.string <- deparse1(substitute(list(...)), collapse = "") or you could change your code to: do.call(stargazer, alist(res)) please note that using alist instead of list is only a workaround, you should still let the package maintainer know of this bug. If the maintainer asks, this is what I used to get the strings above: fun <- \(...) deparse(substitute(list(...))) data("USArrests") res <- lm( Murder ~ UrbanPop, data = USArrests) fun(res) print(do.call("fun", list(res)), max = 9) On Sat, May 28, 2022 at 4:41 PM Arne Henningsen <arne.henningsen at gmail.com> wrote:> > On Sat, 28 May 2022 at 01:21, Uwe Ligges > <ligges at statistik.tu-dortmund.de> wrote: > > On 27.05.2022 17:29, Arne Henningsen wrote: > >> Dear all (cc Marek = maintainer of the stargazer package) > >> > >> We use do.call() to automatically create many LaTeX tables with > >> stargazer but after upgrading to R 4.2.0, this no longer works. I > >> illustrate this with a simple reproducible example: > >> > >> R> data("USArrests") > >> R> res <- lm( Murder ~ UrbanPop, data = USArrests ) > >> R> library(stargazer) > >> R> stargazer(res) # works as expected > >> R> do.call( stargazer, list(res) ) > >> Error in if (is.na(s)) { : the condition has length > 1 > > > > Without looking at the code in detail: The line aboce suggests the code > > needs an any(): if(any(is.na(x))) raher than if(is.na(x)). > > Yes, this is likely a problem in the 'stargazer' package. > > ... but why does the problem occur when using do.call( stargazer, ) > but the problem does *not* occur when using stargazer() directly? > > Best regards, > Arne > > >> Any ideas what we can do so that the last command works with R 4.2.0? > >> > >> /Arne > > -- > Arne Henningsen > http://www.arne-henningsen.name > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Dear Andrew Thanks a lot for investigating the problem and for suggesting a solution and a workaround! I have asked the maintainer of the 'stargazer' package to fix the problem. Until then, we can use the workaround that you suggested. Best regards, Arne On Sat, 28 May 2022 at 23:13, Andrew Simmons <akwsimmo at gmail.com> wrote:> > Hello, > > > I don't have the slightest clue what stargazer is supposed to be > doing, but it seems as though it's trying to create names for the ... > list using: > object.names.string <- deparse(substitute(list(...))) > > It makes an error in assuming that the return value of deparse will be > a character string. For stargazer(res), object.names.string becomes: > "list(res)" > > while for do.call(stargazer, list(res)), object.names.string becomes: > [1] "list(structure(list(coefficients = c(`(Intercept)` > 6.41594246095523, " > [2] "UrbanPop = 0.0209346588197249), residuals = c(Alabama > 5.56984732750071, " > [3] "Alaska = 2.57919391569797, Arizona = 0.009284833466778, Arkansas > = 1.33732459805853, " > [4] "California = 0.679003586449805, Colorado = -0.148845848893771, " > [5] "Connecticut = -4.72791119007405, Delaware = -2.02323789597542, " > [6] "Florida = 7.30928483346678, Georgia = 9.72797800986128, Hawaii > -2.8535191429924, " > [7] "Idaho = -4.94641403722037, Illinois = 2.2464808570076, Indiana > -0.576695284237348, " > [8] "Iowa = -5.40921801367955, Kansas = -1.79762994305707, Kentucky > 2.19545528041907, " > [9] "Louisiana = 7.60237005694293, Maine = -5.3836100607612, Maryland > = 3.4814353981232, " > [ reached getOption("max.print") -- omitted 110 entries ] > > perhaps the package maintainer could change the line from: > object.names.string <- deparse(substitute(list(...))) > to: > object.names.string <- deparse1(substitute(list(...)), collapse = "") > > or you could change your code to: > do.call(stargazer, alist(res)) > > please note that using alist instead of list is only a workaround, you > should still let the package maintainer know of this bug. If the > maintainer asks, this is what I used to get the strings above: > fun <- \(...) deparse(substitute(list(...))) > data("USArrests") > res <- lm( Murder ~ UrbanPop, data = USArrests) > fun(res) > print(do.call("fun", list(res)), max = 9) > > On Sat, May 28, 2022 at 4:41 PM Arne Henningsen > <arne.henningsen at gmail.com> wrote: > > > > On Sat, 28 May 2022 at 01:21, Uwe Ligges > > <ligges at statistik.tu-dortmund.de> wrote: > > > On 27.05.2022 17:29, Arne Henningsen wrote: > > >> Dear all (cc Marek = maintainer of the stargazer package) > > >> > > >> We use do.call() to automatically create many LaTeX tables with > > >> stargazer but after upgrading to R 4.2.0, this no longer works. I > > >> illustrate this with a simple reproducible example: > > >> > > >> R> data("USArrests") > > >> R> res <- lm( Murder ~ UrbanPop, data = USArrests ) > > >> R> library(stargazer) > > >> R> stargazer(res) # works as expected > > >> R> do.call( stargazer, list(res) ) > > >> Error in if (is.na(s)) { : the condition has length > 1 > > > > > > Without looking at the code in detail: The line aboce suggests the code > > > needs an any(): if(any(is.na(x))) raher than if(is.na(x)). > > > > Yes, this is likely a problem in the 'stargazer' package. > > > > ... but why does the problem occur when using do.call( stargazer, ) > > but the problem does *not* occur when using stargazer() directly? > > > > Best regards, > > Arne > > > > >> Any ideas what we can do so that the last command works with R 4.2.0? > > >> > > >> /Arne > > > > -- > > Arne Henningsen > > http://www.arne-henningsen.name > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code.-- Arne Henningsen http://www.arne-henningsen.name
Thanks, everyone, will work on it this weekend. On Sun, May 29, 2022 at 6:52 AM Arne Henningsen <arne.henningsen at gmail.com> wrote:> > Dear Andrew > > Thanks a lot for investigating the problem and for suggesting a > solution and a workaround! I have asked the maintainer of the > 'stargazer' package to fix the problem. Until then, we can use the > workaround that you suggested. > > Best regards, > Arne > > On Sat, 28 May 2022 at 23:13, Andrew Simmons <akwsimmo at gmail.com> wrote: > > > > Hello, > > > > > > I don't have the slightest clue what stargazer is supposed to be > > doing, but it seems as though it's trying to create names for the ... > > list using: > > object.names.string <- deparse(substitute(list(...))) > > > > It makes an error in assuming that the return value of deparse will be > > a character string. For stargazer(res), object.names.string becomes: > > "list(res)" > > > > while for do.call(stargazer, list(res)), object.names.string becomes: > > [1] "list(structure(list(coefficients = c(`(Intercept)` > > 6.41594246095523, " > > [2] "UrbanPop = 0.0209346588197249), residuals = c(Alabama > > 5.56984732750071, " > > [3] "Alaska = 2.57919391569797, Arizona = 0.009284833466778, Arkansas > > = 1.33732459805853, " > > [4] "California = 0.679003586449805, Colorado = -0.148845848893771, " > > [5] "Connecticut = -4.72791119007405, Delaware = -2.02323789597542, " > > [6] "Florida = 7.30928483346678, Georgia = 9.72797800986128, Hawaii > > -2.8535191429924, " > > [7] "Idaho = -4.94641403722037, Illinois = 2.2464808570076, Indiana > > -0.576695284237348, " > > [8] "Iowa = -5.40921801367955, Kansas = -1.79762994305707, Kentucky > > 2.19545528041907, " > > [9] "Louisiana = 7.60237005694293, Maine = -5.3836100607612, Maryland > > = 3.4814353981232, " > > [ reached getOption("max.print") -- omitted 110 entries ] > > > > perhaps the package maintainer could change the line from: > > object.names.string <- deparse(substitute(list(...))) > > to: > > object.names.string <- deparse1(substitute(list(...)), collapse = "") > > > > or you could change your code to: > > do.call(stargazer, alist(res)) > > > > please note that using alist instead of list is only a workaround, you > > should still let the package maintainer know of this bug. If the > > maintainer asks, this is what I used to get the strings above: > > fun <- \(...) deparse(substitute(list(...))) > > data("USArrests") > > res <- lm( Murder ~ UrbanPop, data = USArrests) > > fun(res) > > print(do.call("fun", list(res)), max = 9) > > > > On Sat, May 28, 2022 at 4:41 PM Arne Henningsen > > <arne.henningsen at gmail.com> wrote: > > > > > > On Sat, 28 May 2022 at 01:21, Uwe Ligges > > > <ligges at statistik.tu-dortmund.de> wrote: > > > > On 27.05.2022 17:29, Arne Henningsen wrote: > > > >> Dear all (cc Marek = maintainer of the stargazer package) > > > >> > > > >> We use do.call() to automatically create many LaTeX tables with > > > >> stargazer but after upgrading to R 4.2.0, this no longer works. I > > > >> illustrate this with a simple reproducible example: > > > >> > > > >> R> data("USArrests") > > > >> R> res <- lm( Murder ~ UrbanPop, data = USArrests ) > > > >> R> library(stargazer) > > > >> R> stargazer(res) # works as expected > > > >> R> do.call( stargazer, list(res) ) > > > >> Error in if (is.na(s)) { : the condition has length > 1 > > > > > > > > Without looking at the code in detail: The line aboce suggests the code > > > > needs an any(): if(any(is.na(x))) raher than if(is.na(x)). > > > > > > Yes, this is likely a problem in the 'stargazer' package. > > > > > > ... but why does the problem occur when using do.call( stargazer, ) > > > but the problem does *not* occur when using stargazer() directly? > > > > > > Best regards, > > > Arne > > > > > > >> Any ideas what we can do so that the last command works with R 4.2.0? > > > >> > > > >> /Arne > > > > > > -- > > > Arne Henningsen > > > http://www.arne-henningsen.name > > > > > > ______________________________________________ > > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > > > and provide commented, minimal, self-contained, reproducible code. > > > > -- > Arne Henningsen > http://www.arne-henningsen.name