在我有一个字节列表的情况下,我有时会使用purrr::keep()多个元素,然后结合使用reduce()最终得到一个tibble,但是当我purrr::pluck()或者purrr::keep()只有一个时,做一个reduce是没有意义的.获取tibble的最佳方法是什么,而不是包含tibble的list元素?
我发现keep() %>% enframe() %>% unnest()在某些情况下可以正常工作,但在其他情况下却没有,但无论如何它都显得凌乱.
其他尝试:
require(tidyverse)
#> Loading required package: tidyverse
mylist <- lst(cars, diamonds)
mylist %>% pluck("cars") %>% typeof
#> [1] "list"
mylist %>% pluck("cars") %>% as.tibble() %>% typeof
#> [1] "list"
mylist %>% pluck("cars")[1]
#> Error in .[pluck("cars"), 1]: incorrect number of dimensions
mylist %>% pluck("cars")[[1]]
#> Error in .[[pluck("cars"), 1]]: incorrect number of subscripts
mylist %>% pluck("cars") %>% unlist() %>% typeof
#> [1] "double"
mylist …Run Code Online (Sandbox Code Playgroud) 我有一个单词列表.我正在尝试过滤所有元素共有的列,然后删除最终为零行的任何元素(但由于它们有列,因此在技术上不是空的).它似乎purrr:::compact()是为了这个目的,但我不认为我做得很对.有更好的解决方案吗?
require(tidyverse)
#> Loading required package: tidyverse
mylst <- lst(cars1 = cars %>% as.tibble(), cars2 = cars %>% as.tibble() %>% mutate(speed = speed + 100))
#This produces a list with zero-row tibble elements:
mylst %>% map(function(x) filter(x, speed == 125))
#> $cars1
#> # A tibble: 0 x 2
#> # ... with 2 variables: speed <dbl>, dist <dbl>
#>
#> $cars2
#> # A tibble: 1 x 2
#> speed dist
#> <dbl> <dbl>
#> 1 125. …Run Code Online (Sandbox Code Playgroud) 从knitr 1.12开始,具有功能include_graphics。来自?include_graphics:
使用此功能的主要优点是,它可以移植到knitr支持的所有文档格式的意义上,因此是可移植的,因此您无需考虑是否必须使用例如LaTeX或Markdown语法来嵌入外部图像。
似乎include_graphics()在编织ioslides Rmarkdown演示文稿时处理路径中带有“〜”的路径(到用户目录的快捷方式),但是在编织word / html文档时失败。
ioslide的可复制示例(请注意,这些将在您的桌面上复制Rlogo.png:
---
title: "Rlogo ioslides"
output: ioslides_presentation
---
## Images?
```{r}
require(knitr)
rlogo <- paste0(.libPaths(), "/png/img/Rlogo.png")
include_graphics(rlogo)
file.copy(from = rlogo, to = "~/Desktop")
include_graphics("~/Desktop/Rlogo.png")
```
Run Code Online (Sandbox Code Playgroud)
处理文件:rlogo.Rmd
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc + RTS -K512m -RTS rlogo.utf8.md --to html --from markdown + autolink_bare_uris + ascii_identifiers + tex_math_single_backslash --output rlogo.html --smart-电子邮件混淆无-自包含-变量过渡= 0.4-模板/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rmarkdown/rmd/ioslides/default.html --include-in-标头/var/folders/5_/l71sk6kn29z17n011g8kld5m0000gp/T//RtmpKAAz4I/rmarkdown-str91efb7c6c16.html --mathjax --variable'mathjax-url:https ://mathjax.rstudio.com/latest/MathTeXX.js?config = -AMS-MML_HTMLorMML '输出文件:rlogo.knit.md
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc + RTS -K512m -RTS rlogo.utf8.md-至ioslides_presentation.lua-来自markdown + autolink_bare_uris + ascii_identifiers + tex_math_single_backslash-输出/ var / folders / 5_ …
我有一个 csv,其中一些列有一个引用列,其中包含另一个引用:
"blah blah "nested quote""它会产生解析失败。我不确定这是一个错误还是有一个论据来处理这个问题?
Reprex(文件在此处或内容粘贴在下面):
readr::read_csv("~/temp/shittyquotes.csv")
#> Parsed with column specification:
#> cols(
#> .default = col_double(),
#> INSTNM = col_character(),
#> ADDR = col_character(),
#> CITY = col_character(),
#> STABBR = col_character(),
#> ZIP = col_character(),
#> CHFNM = col_character(),
#> CHFTITLE = col_character(),
#> EIN = col_character(),
#> OPEID = col_character(),
#> WEBADDR = col_character(),
#> ADMINURL = col_character(),
#> FAIDURL = col_character(),
#> APPLURL = col_character(),
#> ACT = col_character(),
#> IALIAS …Run Code Online (Sandbox Code Playgroud) 在 ioslides 中,您可以通过按“w”使幻灯片宽屏。css 或 yaml 标头中是否有任何设置可以使宽屏成为默认设置?