在多行文本上打印单个小标题行

时间:2018-08-02 13:10:56

标签: r tibble drake-r-package

有时最好将tibble中的字符串打印在多行上。示例:https://github.com/ropensci/drake/issues/489。带有长命令的drake plans很难阅读。

library(drake)
pkgconfig::set_config("drake::strings_in_dots" = "literals")
drake_plan(
  u_auckland = make_place(
    Name = "University of Auckland",
    Latitude = -36.8521369,
    Longitude = 174.7688785
  ),
  shapefile = {
    file_out("u-auckland.prj", "u-auckland.shx", "u-auckland.dbf")
    st_write(
      obj = u_auckland,
      dsn = file_out("u-auckland.shp"),
      driver = "ESRI Shapefile",
      delete_dsn = TRUE
    )
  }
)
#> # A tibble: 2 x 2
#>   target     command                                                      
#> * <chr>      <chr>                                                        
#> 1 u_auckland "make_place(Name = \"University of Auckland\", Latitude = -3…
#> 2 shapefile  "{\n    file_out(\"u-auckland.prj\", \"u-auckland.shx\", \"u…

pillar::pillar_shaft()或类似工具可以实现更好的效果吗?我主要关注换行符和缩进(可能使用styler),但是我也对语法突出显示感兴趣,可能使用hightlightcrayon

# A tibble: 2 x 2
  target     command                                             
* <chr>      <drake_cmd>
1 u_auckland make_place(
               Name = "University of Auckland",
               Latitude = -36.8521369,
               Longitude = 174.7688785
             )
2 shapefile  {
               file_out(
                 "u-auckland.prj",
                 "u-auckland.shx",
                 "u-auckland.dbf"
               )
               st_write(
                 obj = u_auckland,
                 dsn = file_out("u-auckland.shp"),
                 driver = "ESRI Shapefile",
                 delete_dsn = TRUE
               )
             }

1 个答案:

答案 0 :(得分:0)

因此,显然这是currently not possible as such,但我的原始用例建议使用great workaround