4

我有一个 CSV 文件startdates.csv,我想将它作为 R 包的一部分提供给同事,名为tabulations. 各个步骤在开发过程中起作用,但是在安装和加载包时, data.frame 列被连接起来。以下是详细信息:

根据Hadley Wickham 的优秀书籍这个非常有用的总结,我输入startdates.csvdata-raw/运行以下脚本将其保存为data/startdates.rda

startdates <- read.csv("data-raw/startdates.csv")
devtools::use_data(startdates, overwrite=T)

按预期工作:

> source("data-raw/get_tabs.r")
Saving startdates as startdates.rda to /home/matthewroberts7/ieTabs/tabulations/data
> startdates
  Dataset Observations Potential_start_date_fields  Earliest    Latest Missing
1   jeval      6445712                           5 30NOV2000 21NOV****   0.04%
2   jhist      7058169                           5 12MAY2001 17SEP****   2.90%
3   ueval       390783                           5 29APR2013 29JUN2016   0.00%

在开发过程中,一切都很好:

> setwd("tabulations")
> devtools::load_all()
Loading tabulations
> tabulations::startdates
  Dataset Observations Potential_start_date_fields  Earliest    Latest Missing
1   jeval      6445712                           5 30NOV2000 21NOV****   0.04%
2   jhist      7058169                           5 12MAY2001 17SEP****   2.90%
3   ueval       390783                           5 29APR2013 29JUN2016   0.00%

但是,当安装包时,就好像原始 csv 已保存为每行一个字符串:

> setwd("..")
> document("tabulations")
Updating tabulations documentation
Loading tabulations
> install("tabulations")
Installing tabulations
...
> reload(inst("tabulations"))
Reloading installed tabulations
> tabulations::startdates
  Dataset.Observations.Potential_start_date_fields.Earliest.Latest.Missing
1                                jeval,6445712,5,30NOV2000,21NOV****,0.04%
2                                jhist,7058169,5,12MAY2001,17SEP****,2.90%
3                                 ueval,390783,5,29APR2013,29JUN2016,0.00%

谁能解释这里发生了什么?非常感谢。

编辑:R v3.4.2,devtools v1.13.4

4

0 回答 0