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



我正在创建我的第一个R包。其中一个函数将接受一个vcf文件,并将其格式化后输出到R环境中以供进一步使用。下面是代码!

输入图片描述

在我安装了这个包之后,我得到的是:

> devtools::install()
── R CMD build ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔  checking for file 'C:UsersraymuOneDriveDocumentsRLoFmyfirstpackage/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::检查并得到了这个,但我不确定它是什么意思

> 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:UsersraymuOneDriveDocumentsRLoFmyfirstpackage/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环境中有一个格式化的表,可以被用户进一步利用。我有一个独立的脚本,我已经开发和工作得很好,但想把它转换成一个软件包,便于使用和部署我的论文研究如果我还遗漏了什么信息,请告诉我。

save行放在函数末尾。将return(tmp_vcf_data)tmp_vcf_data作为函数的最后一行。这样你的函数将返回你格式化的vcf文件。

然后调用函数并将输出赋值给一个对象。例如output <- load_vcf(inline)

相关内容

最新更新