本文介绍了R包开发中的代码组织的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

R中开发软件包时,所有R源文件都放在子目录R/中,所有编译后的代码都放在子目录src/中.

When developing packages in R all R source files are put in the subdirectory R/, and all compiled code is put in the subdirectory src/.

我想在这些文件夹中的文件中添加一些组织,而不是将所有内容都转储到顶层.例如,假设我正在开发一个客户端-服务器应用程序.从逻辑上讲,我想在R/client/中组织所有客户端R源文件,在R/server/中组织所有服务器R源文件.

I would like to add some organisation to files within these folders, rather than have everything dumped at the top level. For example, lets say I'm hypothetically developing a client-server application. Logically, I would like to organise all my client R source files in R/client/ and all my server R source files in R/server/.

开发程序包时是否可以在子文件夹中组织代码,如果可以,怎么办? 编写R扩展手册不提供任何指导,R CMD build也不检测文件存储在R/下的子文件夹中.

Is it possible to organise code in subfolders when developing a package, and if so, how? The Writing R Extensions manual doesn't offer any guidance, nor does R CMD build detect files stored in subfolders under R/.

推荐答案

如果没有其他设置(如定义自定义makefile),则不能使用子文件夹.最好的办法是使用前缀:client-a.rclient-b.rserver-a.rserver-b.r等.

You can't use subfolders without additional setup (like defining a custom makefile). The best you can do is to use prefixes: client-a.r, client-b.r, server-a.r, server-b.r, etc.

这篇关于R包开发中的代码组织的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 06:48