我正在创建我的第一个R包,但似乎无法获得一个函数来输出文件到rstudio环境中

6pp0gazn  于 2022-12-05  发布在  其他
关注(0)|答案(1)|浏览(246)

我正在创建我的第一个R包。其中一个函数将接收一个vcf文件,并将其格式化输出到R env中以供进一步使用。下面是代码!
enter image description here
安装软件包后,我得到的是:

> devtools::install()
── R CMD build ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔  checking for file 'C:\Users\raymu\OneDrive\Documents\R\LoF\myfirstpackage/DESCRIPTION' ...
─  preparing 'myfirstpackage':
E  checking DESCRIPTION meta-information ...
   Malformed maintainer field.
   
   See section 'The DESCRIPTION file' in the 'Writing R Extensions'
   manual.
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'Rcmd.exe' failed
---
Exit status: 1
stdout & stderr: <printed>
---

当我尝试对测试vcf文件执行该函数时,没有出现错误,但在环境中没有任何结果
我试过devtools::check,得到了这个,但不确定它是什么意思

> devtools::check()
══ Documenting ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
ℹ Updating myfirstpackage documentation
ℹ Loading myfirstpackage
Warning: Skipping NAMESPACE
✖ It already exists and was not generated by roxygen2.

══ Building ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Setting env vars:
• CFLAGS    : -Wall -pedantic
• CXXFLAGS  : -Wall -pedantic
• CXX11FLAGS: -Wall -pedantic
• CXX14FLAGS: -Wall -pedantic
• CXX17FLAGS: -Wall -pedantic
• CXX20FLAGS: -Wall -pedantic
── R CMD build ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔  checking for file 'C:\Users\raymu\OneDrive\Documents\R\LoF\myfirstpackage/DESCRIPTION' (405ms)
─  preparing 'myfirstpackage':
E  checking DESCRIPTION meta-information ...
   Malformed maintainer field.
   
   See section 'The DESCRIPTION file' in the 'Writing R Extensions'
   manual.
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'Rcmd.exe' failed
---
Exit status: 1
stdout & stderr: <printed>
---
Type .Last.error to see the more details.
> .Last.error
<system_command_status_error/rlib_error_3_0/rlib_error/error>
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'Rcmd.exe' failed
---
Exit status: 1
stdout & stderr: <printed>
---
Backtrace:
 1. devtools::check()
 2. withr::with_envvar(pkgbuild::compiler_flags(FALSE), action = "prefix", …
 3. base::force(code)
 4. pkgbuild::build(pkg$path, tempdir(), args = build_args, quiet = quiet, …
 5. withr::with_temp_libpaths(rcmd_build_tools(options$cmd, c(options$path, …
 6. base::force(code)
 7. pkgbuild::rcmd_build_tools(options$cmd, c(options$path, options$args), …
 8. pkgbuild::with_build_tools({ …
 9. withr::with_path(rtools_path(), code)
10. base::force(code)
11. base::withCallingHandlers(callr::rcmd_safe(..., env = env, spinner = FALSE, …
12. callr::rcmd_safe(..., env = env, spinner = FALSE, show = FALSE, …
13. callr:::run_r(options)
14. base::with(options, with_envvar(env, do.call(processx::run, c(list(bin, …
15. base::with.default(options, with_envvar(env, do.call(processx::run, …
16. base::eval(substitute(expr), data, enclos = parent.frame())
17. base::eval(substitute(expr), data, enclos = parent.frame())
18. callr:::with_envvar(env, do.call(processx::run, c(list(bin, args = real_cmdargs, …
19. base::force(code)
20. base::do.call(processx::run, c(list(bin, args = real_cmdargs, stdout_line_callback = real_callback(stdout), …
21. (function (command = NULL, args = character(), error_on_status = TRUE, …
22. base::throw(new_process_error(res, call = sys.call(), echo = echo, …
23. | base::signalCondition(cond)
24. (function (e) …
25. asNamespace("callr")$err$throw(e)

我期待在Rstudio环境中有一个格式化的表,可以由用户进一步使用。我有一个单独的脚本,我已经开发和工作很好,但想把它转换成一个包,以方便使用和部署我的论文研究请让我知道,如果有任何其他信息,我错过了。

lb3vh1jj

lb3vh1jj1#

save行放在函数的最后,将return(tmp_vcf_data)tmp_vcf_data作为函数的最后一行,这样函数将返回格式化的vcf文件。
然后调用函数并将输出赋给一个对象,例如output <- load_vcf(inline)

相关问题