0

有时需要tibble在多行中打印一个字符串。示例:https ://github.com/ropensci/drake/issues/489 。drake带有长命令的计划很难阅读。

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),但我也对语法高亮感兴趣,可能使用hightlightand crayon

# 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
               )
             }
4

1 回答 1

0

因此,显然这目前是不可能的,但是为我的原始用例建议了一个很好的解决方法。

于 2018-08-03T00:47:14.060 回答