数据集未出现在我的R包中

时间:2016-02-17 20:35:21

标签: r devtools

我想在我正在构建的包中包含数据集。我按照primer中的所有步骤进行了操作。

  • 创建数据子目录并将数据集另存为myPackage/data/this_dataset.Rdata
  • 创建包含.R条评论的Roxygen2个文件,保存为myPackage/R/this_dataset-data.R
  • LazyData: true文件中加入DESCRIPTION行。

然后我安装它:

> library("devtools")
> setwd("D:/workspace/myPackage")
> install()
Installing aPackage
Skipping 1 package ahead of CRAN: data.table
"C:/PROGRA~1/R/R-32~1.3/bin/x64/R" --no-site-file --no-environ --no-save --no-restore CMD INSTALL  \
  "D:/workspace/myPackage" --library="C:/Users/aUser/Documents/R/win-library/3.2" --install-tests 

* installing *source* package 'aPackage' ...
** R
** data
*** moving datasets to lazyload DB
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (aPackage)

Reloading installed aPackage

所以它看起来好像有数据集。

但是我无法加载数据集。 print(this_dataset)应该使用延迟加载但返回“找不到对象”错误。 data(this_dataset)返回“未找到数据集”。我这样做:data(package='aPackage')并获得no data sets found

我做错了什么?

1 个答案:

答案 0 :(得分:1)

我不确定为什么这很重要,但是将文件名从bool read_code(string file_name, vector<funct> &my_functions, vector<variable> & v) { vector<string> code; string s; std::size_t found; bool flag; funct new_function; ifstream in; in.open(file_name.c_str()); if(in.is_open()) { //read in file line by line and put it into a vector called code while(in.peek()!=EOF) { getline(in,s); code.push_back(s); } in.clear(); in.close(); //read through each line of the code, determine if it's a variable or function (definition or call) //here it makes reference to functions (listed following this one) which will actually decompose the line //for information for(int i=0;i<code.size();i++) { //check if it's a variable declaration found = code[i].find("var"); if(found!=std::string::npos) //its a variable declaration get_variable_declaration(code[i], v); //ERROR CANNOT FIND.. //check if it's a function. it'll go in the list of functions found = code[i].find("funct"); if (found!=std::string::npos) //that means it's a function { new_function.funct_name=get_function_name(code[i]); new_function.commands.clear(); i+=2; //skip over the open curly brace flag=false; while(!flag) { found = code[i].find("}"); if(found==std::string::npos) { new_function.commands.push_back(code[i]); i++; } else { my_functions.push_back(new_function); flag=true; } } } } return true; } else { cout << "Cannot locate this file" << endl; return false; } } 更改为myPackage/data/this_dataset.Rdata(注意文件扩展名大小写的差异)似乎已经产生了不同。