data.table throws “object not found” error [duplicate]

点点圈 提交于 2019-12-03 23:42:21

Great reproducible question! Here's what I get. You didn't post your output as well, so perhaps you don't get the same output at me. I've split the output and placed HERE where the problem might be.

$ R
R version 3.1.0 (2014-04-10) -- "Spring Dance"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

> library(devtools)
> setwd(tempdir())
> # make dummy package called foo
> create("foo")
Creating package foo in .
No DESCRIPTION found. Creating with values:

Package: foo
Title: 
Description: 
Version: 0.1
Authors@R: # getOptions('devtools.desc.author')
Depends: R (>= 3.1.0)
License: # getOptions('devtools.desc.license')
LazyData: true
> setwd("foo")
> 
> # add data.table as a package dependency
> a <- readLines("DESCRIPTION")
> depends.idx <- grepl("Depends", a)
> a[depends.idx] <- paste0(a[depends.idx], ", data.table")
> writeLines(a, "DESCRIPTION")
> 
> # create a dummy function 
> writeLines("myfunction <- function() {a <- data.table(b=1); return(a[,b])}",
+             "R/foo.R")
> 
> # check and throw error
> check()
Loading required package: roxygen2
Updating foo documentation
Loading foo

HERE :

Invalid DESCRIPTION:
Authors@R field gives no person with author role.
Authors@R field gives no person with maintainer role and email address.

See the information on DESCRIPTION files in section 'Creating R packages' of the 'Writing R Extensions' manual.

Loading required package: data.table
data.table 1.9.2  For help type: help("data.table")

Attaching package: ‘data.table’

The following object is masked from ‘package:bit’:

    setattr

Updating collate directive in  /tmp/Rtmp0h3yz9/foo/DESCRIPTION 
Updating namespace directives
Writing foo.Rd
'/usr/lib/R/bin/R' --vanilla CMD build '/tmp/Rtmp0h3yz9/foo' --no-manual --no-resave-data 

* checking for file '/tmp/Rtmp0h3yz9/foo/DESCRIPTION' ... OK
* preparing 'foo':

HERE :

* checking DESCRIPTION meta-information ... ERROR
Authors@R field gives no person with author role.
Authors@R field gives no person with maintainer role and email address.

See the information on DESCRIPTION files in section 'Creating R
packages' of the 'Writing R Extensions' manual.

Error: Command failed (1)
> library(foo)
> myfunction()
Error in `[.data.frame`(x, i, j) : object 'b' not found
> 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!