2014-10-15 8 views
5

Ich baue ein Paket mit Rcpp mit Rstudio. Alles funktionierte gut, bis ich das Markup für die Dokumentation zu meiner Funktionsdatei hinzugefügt habe. Ich hoffe, ich übersehe etwas Offensichtliches.Rstudio Roxygen2 @importFrom Parsing Funktion Header

Hier ist meine R Funktion file:

#' @useDynLib tablr 
#' @importFrom Rcpp sourceCpp 
#' 
#' fast.table 
#' 
#' C++ implementation of the R table function. Only supports numeric 
#' vectors. Does not currently handle NAs. 
#' 
#' @param x1 Variable 1 
#' @param x2 Variable 2 
#' @return A table object equal in every way to an R table object with the same 
#' inputs 
#' 
#' @export fast.table 
fast.table <- function(x1, x2) { 
    nms <- c(deparse(substitute(x1)), deparse(substitute(x2))) 
    cpp_table(as.numeric(x1), as.numeric(x2), as.character(nms)) 
} 

Und nach devtools::document() dies ausgeführt wird, was die Namespace-Datei wie folgt aussieht:

# Generated by roxygen2 (4.0.2): do not edit by hand 

export(fast.table) 
importFrom(Rcpp,"C++") 
importFrom(Rcpp,Does) 
importFrom(Rcpp,NAs.) 
importFrom(Rcpp,Only) 
importFrom(Rcpp,R) 
importFrom(Rcpp,currently) 
importFrom(Rcpp,fast.table) 
importFrom(Rcpp,function.) 
importFrom(Rcpp,handle) 
importFrom(Rcpp,implementation) 
importFrom(Rcpp,not) 
importFrom(Rcpp,numeric) 
importFrom(Rcpp,of) 
importFrom(Rcpp,sourceCpp) 
importFrom(Rcpp,supports) 
importFrom(Rcpp,table) 
importFrom(Rcpp,the) 
importFrom(Rcpp,vectors.) 
useDynLib(tablr) 

Wie Sie sehen können, ist die @importFrom Tag die Funktion Parsen Header-Text und versuchen, jedes "Wort" aus dem Rcpp Paket zu importieren.

Die Fehlermeldung nach devtools::document() ausgeführt wird:

Error: object 'C++' is not exported by 'namespace:Rcpp' 
Execution halted 

Exited with status 1. 

Und die Session Info:

> devtools::session_info() 
Session info---------------------------------------------------------------------------------- 
setting value      
version R version 3.1.1 (2014-07-10) 
system x86_64, mingw32    
ui  RStudio (0.98.1049)   
language (EN)       
collate English_United States.1252 
tz  America/Chicago    

Packages-------------------------------------------------------------------------------------- 
package * version date  source   
devtools  1.6.1 2014-10-07 CRAN (R 3.1.1) 
Rcpp   0.11.3 2014-09-29 CRAN (R 3.1.1) 
roxygen2  4.0.2 2014-09-02 CRAN (R 3.1.1) 
rstudioapi 0.1  2014-03-27 CRAN (R 3.1.1) 
stringr  0.6.2 2012-12-06 CRAN (R 3.1.0) 
tablr  * 0.1  <NA>  local   

Antwort

4

Gelöst von NULL nach dem @importFrom Tag setzen:

#' @useDynLib tablr 
#' @importFrom Rcpp sourceCpp 
NULL 

#' fast.table 
#' 
#' C++ implementation of the R table function. Only supports numeric 
#' vectors. Does not currently handle NAs. 
#' 
#' @param x1 Variable 1 
#' @param x2 Variable 2 
#' @return A table object equal in every way to an R table object with the same 
#' inputs 
#' 
#' @export fast.table 
fast.table <- function(x1, x2) { 
    nms <- c(deparse(substitute(x1)), deparse(substitute(x2))) 
    cpp_table(as.numeric(x1), as.numeric(x2), as.character(nms)) 
}