【问题标题】:sjplot sjt.frq in new window / tabsjplot sjt.frq 在新窗口/标签中
【发布时间】:2015-02-22 16:56:11
【问题描述】:

我正在使用 sjPlot 以获得“漂亮”的表格。我设法创建了一个非常好的意外事件和另一个表格,为我提供了一个变量的频率。

一切都很好,应该是这样 - 除了一件事: 我使用 RStudio,当我运行包含多个 sjPlot 表作为输出的代码时,我只能访问最新的一个。与 RStudio 的图形窗口不同,您可以在输出中来回单击,我在这里只看到最后一个表格。

有没有办法创建一个新的选项卡或窗口,以便我可以运行我的代码并访问我创建的所有表?

那太酷了!

【问题讨论】:

    标签: r tabs rstudio sjplot


    【解决方案1】:

    目前,RStudio 中的查看器窗格没有历史记录功能。您可以改为在浏览器中打开表格(或者另外,查看器窗格中有一个图标),因此您有多个浏览器选项卡,每个选项卡都有一个表格输出。

    或者您“连接”多个表并在查看器窗格中显示它们,但是,这样做相当费力。

    # create and save first HTML-table
    part1 <- sjt.lm(fit1, fit2)
    # create and save second HTML-table
    part2 <- sjt.lm(fit3, fit4)
    # browse temporary file
    htmlFile <- tempfile(fileext=".html")
    write(sprintf("<html><head>%s</head><body>%s<p></p>%s</body></html>",
                  part1$page.style,
                  part1$page.content,
                  part2$page.content),
          file = htmlFile)
    viewer <- getOption("viewer")
    if (!is.null(viewer)) viewer(htmlFile) else     
    utils::browseURL(htmlFile)
    

    【讨论】:

      【解决方案2】:

      谢谢丹尼尔! 这实际上真的很有帮助!

      我还发现windows() 还通过 RStudio 创建了新的数据窗口(这就是为什么我将其发布为答案而不仅仅是评论...)。 这可能对其他 RStudio 用户也很有趣 :-)

      这是一些从我的脚本中快速复制出来的示例代码:

      scatter <- ggplot(na.action=na.exclude, spending.analysis, aes(age, money))
      windows()
      scatter + 
              geom_point(aes(color = school), alpha = 0.7) +
              geom_smooth( method = "lm", color = "dark blue", alpha = 0.05, fill = "blue", na.action = na.exclude) +
              facet_grid(. ~ school) +
              theme_bw() +
              scale_color_manual(values = group.colors)
      

      我认为这解释了在哪里放置 windows() 命令

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-04-07
        • 2011-07-05
        • 2014-11-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多