I have trying hard to make a r package myself. I followed the instruction in previous question in * on how to develop package for layman. Here are the steps I tool following the previous question.
我一直在努力自己做一个r包。我遵循了*上关于如何为外行开发包的问题。下面是我在前面的问题中使用的步骤。
-
Run R code in fresh R session
在新的R会话中运行R代码
# random DNA function randDNA = function(n){ paste(sample(c("A", "C", "T", "G"), n, replace = TRUE), collapse = "") } # DNA to RNA function dna2rna <- function(inputStr) { if (!is.character(inputStr)) stop("need character input") is = toupper(inputStr) chartr("T", "U", is) } # complementary sequence function compSeq <- function(inputStr){ chartr("ACTG", "TGAC", inputStr) } # example data dnaseq1 <- c("ATTGTATCTGGGTATTTCCCTTAATTGGGGCCTTT") dnaseq2 <- c("TGGGGTAAACCCGGTTTAAAATATATATATTTTT") myseqdata <- data.frame(dnaseq1, dnaseq2) save(myseqdata, file = "myseqdata.RData")
-
Install Rtools Install R package utils
安装Rtools安装程序包
-
Pefrom the following task in R
在R中完成以下任务
require(utils) package.skeleton(list = c("randDNA","dna2rna", "compSeq", "myseqdata"), name = "dnatool",environment = .GlobalEnv, path = "c:", force = FALSE)
-
Edit system environment variable path to following in windows 7
在windows 7中编辑系统环境变量路径
C:\Rtools\bin;C:\Rtools\perl\bin;C:\Rtools\MinGW\bin; C:\Program Files\R\R-2.14.2\bin\x64;
(type
>path
in command line to check if the path is properly set.(在命令行中键入>路径,检查路径是否设置正确。
-
Copy the folder dnatool in step (3) and put in new folder named rpackage, Now change directory to this folder (in DOS)
复制步骤(3)中的文件夹dnatool,并放入名为rpackage的新文件夹,现在将目录更改为该文件夹(在DOS中)
c: \ repackage> R CMD build dnatool c: \ repackage> Rcmd build dnatool
Edit: I am sometime getting dnatool.zip but other times dnatool.tar.gx
编辑:我有时会喝*醇。zip但是其他时间是dnatol .tar.gx
-
Checking package in command line (DOS)
在命令行中检查包(DOS)
c: \ repackage> R CMD check dnatool
I was able to pack it as "dnatool.zip" in windows.
我可以把它包装成“dnatool”。在windows zip”。
How can compile for MAC or unix source ? What steps are different ?
如何为MAC或unix源代码编译?哪些步骤是不同的?
Unix source: dnatool.tar.gz
Mac OS X binary: dnatool.tgz
Do I need Mac computer to do. I do have linux virtualbox and installed ubuntu in it ?
我需要Mac电脑吗?我有linux virtualbox并在里面安装了ubuntu ?
Edit:
编辑:
Should I use the following commad to get sourcode binary from step (3) folder dnatool ?
我是否应该使用下面的commad从步骤(3)文件夹dnatool获得源代码二进制文件?
$ tar -zcvf dnatool.tar.gz/home/dnatool
1 个解决方案
#1
2
The package that was created using R CMD build
can be installed on other OS types. Even if your package contains source code other than R (c or c++) this is the case. Only when you create a binary distribution (I think by adding --binary to the r cmd build call) the package becomes platform specific. The tools needed to build packages are often already installed under linux or mac. So if you create a source distribution, it should work under all the major distributions. To create a mac binary, you need either a mac, or create a cross-compiler environment. The second option could be quite a challenge, I say you could give to a google. Do note that if you upload your package to CRAN, all building of packages is done for you.
使用R CMD构建创建的包可以安装在其他OS类型上。即使您的包包含除R (c或c++)之外的源代码,也是如此。只有当您创建一个二进制发行版(我认为是通过向r cmd构建调用添加二进制)时,包才会成为特定于平台的。构建包所需的工具通常已经安装在linux或mac下,所以如果您创建了一个源分布,那么它应该在所有主要的发行版下面工作。要创建一个mac二进制文件,您需要一个mac,或者创建一个跨编译环境。第二个选择可能是一个相当大的挑战,我说你可以给一个谷歌。请注意,如果您将包上传到CRAN,那么所有构建包的工作都是为您完成的。
#1
2
The package that was created using R CMD build
can be installed on other OS types. Even if your package contains source code other than R (c or c++) this is the case. Only when you create a binary distribution (I think by adding --binary to the r cmd build call) the package becomes platform specific. The tools needed to build packages are often already installed under linux or mac. So if you create a source distribution, it should work under all the major distributions. To create a mac binary, you need either a mac, or create a cross-compiler environment. The second option could be quite a challenge, I say you could give to a google. Do note that if you upload your package to CRAN, all building of packages is done for you.
使用R CMD构建创建的包可以安装在其他OS类型上。即使您的包包含除R (c或c++)之外的源代码,也是如此。只有当您创建一个二进制发行版(我认为是通过向r cmd构建调用添加二进制)时,包才会成为特定于平台的。构建包所需的工具通常已经安装在linux或mac下,所以如果您创建了一个源分布,那么它应该在所有主要的发行版下面工作。要创建一个mac二进制文件,您需要一个mac,或者创建一个跨编译环境。第二个选择可能是一个相当大的挑战,我说你可以给一个谷歌。请注意,如果您将包上传到CRAN,那么所有构建包的工作都是为您完成的。