在Windows/Linux中为Mac创建软件包 [英] Creating package for Mac in Windows / Linux

查看:118
本文介绍了在Windows/Linux中为Mac创建软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力制作自己的r包装.我按照如何为外行开发程序包上的stackoverflow中上一个问题中的说明进行操作.这是我根据上一个问题处理的步骤.

I have trying hard to make a r package myself. I followed the instruction in previous question in stackoverflow on how to develop package for layman. Here are the steps I tool following the previous question.

  1. 在全新的R会话中运行R代码

  1. Run R code in fresh R session

# 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")

  • 安装 Rtools 安装R包

  • Install Rtools Install R package utils

    从R中的以下任务中删除

    Pefrom the following task in R

    require(utils)
    package.skeleton(list = c("randDNA","dna2rna", "compSeq", "myseqdata"), 
    name = "dnatool",environment = .GlobalEnv, path = "c:", force = FALSE)
    

  • 在Windows 7中编辑要遵循的系统环境变量路径

  • Edit system environment variable path to following in windows 7

    C:\Rtools\bin;C:\Rtools\perl\bin;C:\Rtools\MinGW\bin; 
    C:\Program Files\R\R-2.14.2\bin\x64; 
    

    (在命令行中键入>path来检查路径是否正确设置.

    (type >path in command line to check if the path is properly set.

    在步骤(3)中复制文件夹dnatool并放入名为rpackage的新文件夹,现在将目录更改为该文件夹(在DOS中)

    Copy the folder dnatool in step (3) and put in new folder named rpackage, Now change directory to this folder (in DOS)

    c: \ repackage>  R CMD build dnatool 
    c: \ repackage>  Rcmd build dnatool 
    

    我有时会得到dnatool.zip,而其他时候会得到dnatool.tar.gx

    在命令行(DOS)中检查软件包

    Checking package in command line (DOS)

    c: \ repackage> R CMD check dnatool
    

  • 我能够在Windows中将其打包为"dnatool.zip".

    I was able to pack it as "dnatool.zip" in windows.

    如何为MAC或Unix源进行编译?有哪些不同的步骤?

    How can compile for MAC or unix source ? What steps are different ?

    Unix source:     dnatool.tar.gz
    Mac OS X binary: dnatool.tgz
    

    我需要Mac电脑吗?我有linux virtualbox并在其中安装了ubuntu吗?

    Do I need Mac computer to do. I do have linux virtualbox and installed ubuntu in it ?

    应该使用以下commad以获得sourcode二进制来自步骤(3)夹dnatool?

    Should I use the following commad to get sourcode binary from step (3) folder dnatool ?

    $ tar -zcvf dnatool.tar.gz/home/dnatool
    

    推荐答案

    使用R CMD build创建的程序包可以安装在其他OS类型上.即使您的软件包包含R(c或c ++)以外的源代码,也是如此.仅当您创建二进制发行版时(我认为通过在r cmd构建调用中添加--binary),程序包才成为特定于平台的.生成软件包所需的工具通常已经安装在linux或mac下.因此,如果您创建源代码发行版,则它应该在所有主要发行版下都可以正常工作.要创建Mac二进制文件,您需要Mac或创建交叉编译器环境.第二种选择可能是一个很大的挑战,我说你可以给谷歌.请注意,如果您将软件包上传到CRAN,则所有软件包的构建都已为您完成.

    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.

    这篇关于在Windows/Linux中为Mac创建软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆