使用R中的参数构建请求URL的最佳方法是什么?到目前为止,我想出了这个:
library(magrittr)
library(httr)
library(data.table)
url <- list(hostname = "geo.stat.fi/geoserver/vaestoalue/wfs",
scheme = "https",
query = list(service = "WFS",
version = "2.0.0",
request = "GetFeature",
typename = "vaestoalue:kunta_vaki2017",
outputFormat = "application/json")) %>%
setattr("class","url")
request <- build_url(url)
Run Code Online (Sandbox Code Playgroud)
我喜欢我现在的代码是,我可以轻松更改参数值并重建URL.
此外,生成的url正确地进行了html编码:
https://geo.stat.fi/geoserver/vaestoalue/wfs/?service=WFS&version=2.0.0&request=GetFeature&typename=vaestoalue%3Akunta_vaki2017&outputFormat=application%2Fjson
Run Code Online (Sandbox Code Playgroud)
但是加载data.table库,只是为了构建一个url,感觉不对.这样做有好处吗?
我的包中的这个测试与devtools::test(). 在线 Travis 构建也进展顺利。
test_that("Package style", {
lintr::expect_lint_free()
})
Run Code Online (Sandbox Code Playgroud)
然而,devtools::check()它失败了。错误信息是
invalid 'path' argument
Backtrace:
1. lintr::expect_lint_free()
2. lintr::lint_package(...)
3. base::normalizePath(path, mustWork = FALSE)
4. base::path.expand(path)
Run Code Online (Sandbox Code Playgroud)
我在 Windows 上运行 R 版本 3.6.3 (2020-02-29)、testthat 2.3.2 和 lintr 2.0.1。
我认为问题是 lintr 不知道要 lintr 哪个文件。
有人可以向我指出这个问题的解决方案是什么吗?
当我预览 R Notebook 时,HTML 输出包含奇怪的字符。
这个块代码和输出
在 HTML 中呈现为
我应该如何解决这个问题?
会话信息:
R 版本 3.6.0 (2019-04-26) 平台:x86_64-w64-mingw32/x64(64 位) 运行环境:Windows 10 x64(内部版本 17763)
矩阵产品:默认
语言环境:
1 LC_COLLATE=Dutch_Netherlands.1252 LC_CTYPE=Dutch_Netherlands.1252 LC_MONETARY=Dutch_Netherlands.1252 LC_NUMERIC=C
[5] LC_TIME=Dutch_Netherlands.1252
其他附包:
1 plotly_4.9.0 DT_0.6 shinydashboard_0.7.1 shiny_1.3.2 lubridate_1.7.4 forcats_0.4.0
[7] stringr_1.4.0 dplyr_0.8.1 purrr_0.3.2 readr_1.3.1 tidyr_0.8.3 tibble_2.1.1
[13] ggplot2_3.1.1 tidyverse_1.2.1
通过命名空间加载(且未附加):
1 tidyselect_0.2.5 xfun_0.7haven_2.1.0lattice_0.20-38 colorspace_1.4-1 generics_0.0.2 viridisLite_0.3.0 htmltools_0.3.6
[9] base64enc_0.12.2ya rlang_0.3.4 pillar_1.4.0 later_0.8.0 glue_1.3.1 withr_2.1.2 modelr_0.1.4
[17] readxl_1.3.1 plyr_1.8.4 munsell_0.5.0 gtable_0.3.0 cellranger_1.1.0 rvest_0.3.4 htmlwidgets_1.3 evaluate_0.14
[25] knitr_1。 23 httpuv_1.5.1 crosstalk_1.0.0 broom_0.5.2 Rcpp_1.0.1 …