我正在设计一辆AT/BlueskyR package的车,我正在try 一种非传统的 struct .由于通过JSON lexicon defined here非常详细地记录了Bluesky方法,因此我将这些文件复制到/inst目录中,因此我的包 struct 如下所示:

├── DESCRIPTION
├── LICENSE
├── LICENSE.md
├── NAMESPACE
├── R
│   ├── bluesky.R
│   ├── helpers.R
│   ├── lexicon.R
│   └── types.R
├── README.Rmd
├── README.md
├── blueRsky.Rproj
├── inst
│   └── lexicons
│       ├── app
│       │   └── bsky
│       │       ├── actor
│       │       │   ├── defs.json
│       │       │   ├── getProfile.json
│       │       │   ├── getProfiles.json
│       │       │   ├── getSuggestions.json
│       │       │   ├── profile.json
│       │       │   ├── searchActors.json
│       │       │   └── searchActorsTypeahead.json
│       │       ├── embed
│       │       │   ├── external.json
│       │       │   ├── images.json
│       │       │   ├── record.json
│       │       │   └── recordWithMedia.json
│       │       ├── feed
│       │       │   ├── defs.json
│       │       │   ├── getAuthorFeed.json
│       │       │   ├── getLikes.json
│       │       │   ├── getPostThread.json
│       │       │   ├── getPosts.json
│       │       │   ├── getRepostedBy.json
│       │       │   ├── getTimeline.json
│       │       │   ├── like.json
│       │       │   ├── post.json
│       │       │   └── repost.json
│       │       ├── graph
│       │       │   ├── follow.json
│       │       │   ├── getFollowers.json
│       │       │   ├── getFollows.json
│       │       │   ├── getMutes.json
│       │       │   ├── muteActor.json
│       │       │   └── unmuteActor.json
│       │       ├── notification
│       │       │   ├── getUnreadCount.json
│       │       │   ├── listNotifications.json
│       │       │   └── updateSeen.json
│       │       ├── richtext
│       │       │   └── facet.json
│       │       └── unspecced
│       │           └── getPopular.json
│       └── com
├── man
│   ├── bsky_get_profile.Rd
│   ├── bsky_get_session.Rd
│   ├── bsky_get_timeline.Rd
│   └── bsky_search_actors.Rd
└── tests
    ├── testthat
    │   └── test-lexicon.R
    └── testthat.R

我有一些函数可以随后查找词典模式,例如

load_schema <- function(id) {
  loc <- c("lexicons", strsplit(id, "\\.")[[1]]) |>
    paste0(collapse = "/") |>
    paste0(".json")

  file_path <- system.file(loc, package = "blueRsky", mustWork = FALSE)
  cat("file_path:", file_path, "\n")
  if (!file.exists(file_path)) {
    stop(paste("Schema", id, "not found"))
  }

  jsonlite::read_json(system.file(loc, package = "blueRsky", mustWork = TRUE))
}

这非常好,因为它允许我抽象许多用于构造请求的样板.

这在本地运行得很好,我可以安装这个包,并且我的所有测试都通过了,但它没有通过R CMD判断.我认为原因是R CMD Check正在从词典目录中删除一些文件.输出为:

── R CMD build ──────────────────────────────────────────────────────────────────
✔  checking for file ‘/Users/colinfraser/projects/blueRsky/DESCRIPTION’ ...
─  preparing ‘blueRsky’: (1.1s)
✔  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts (346ms)
─  checking for empty or unneeded directories
   Removed empty directory ‘blueRsky/inst/lexicons/com’
─  building ‘blueRsky_0.0.0.9000.tar.gz’

Removed empty directory ‘blueRsky/inst/lexicons/com’.

这并不好,因为实际上该目录并不是空的,它只是在其中嵌套了文件夹.后来,它失败了,因为它不能加载包代码.

我能做些什么来阻止R CMD Check删除此文件吗?或者这里有没有其他地方出了问题?我知道这是一个有点不寻常的包 struct ,但如果我能让它工作,它似乎真的会工作得很好.

推荐答案

R删除了目录inst/com/,因为at the time of package building它被认为是空的.R不知道您计划稍后在那里存储文件;它只是看到一个空目录,并旨在清理文件,以创建一个更整洁的包,而不会有任何混乱.

解决这个问题的办法不言而喻:将一个文件放到目录中,可能是inst/com/README.md个,或者,更起码是一个零字节的占位符,通过

$ touch inst/com/.keep.this.directory

假设您的操作系统确实有一个touch二进制代码.

R相关问答推荐

如何在x轴下方画一条带有箭头的线?

如何按照特定顺序拆分字符?

手工PCA上的载体与输出双图不匹配

如何将y轴上的线定位得彼此更近

如何在弹性表中为类别值的背景上色

在R中列表的结尾添加数字载体

根据R中的另一个日期从多列中 Select 最近的日期和相应的结果

Highcharter多次钻取不起作用,使用不同方法

如何删除gggvenn与gggplot绘制的空白?

整数成随机顺序与约束R?

如何在kableextra调用cell_spec()中忽略NA?

如何自定义3D散点图的图例顺序?

为了网络分析目的,将数据框转换为长格式列联表

有没有一种方法可以同时对rhandsontable进行排序和从rhandsontable中删除?

警告消息";没有非缺失的参数到min;,正在返回数据中的inf";.表分组集

如何提取R中其他字符串和数字之间的字符串?

如何移动点以使它们的打印不重叠

Ggplot2如何找到存储在对象中的残差和拟合值?

如何更改包中函数中的参数?

如何使投篮在R中保持一致