Reputation: 11366
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.
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")
Pefrom the following task in 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
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)
c: \ repackage> R CMD build dnatool
c: \ repackage> Rcmd build dnatool
Edit: I am sometime getting dnatool.zip but other times dnatool.tar.gx
Checking package in command line (DOS)
c: \ repackage> R CMD check dnatool
I was able to pack it as "dnatool.zip" in windows.
How can compile for MAC or unix source ? What steps are different ?
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 ?
Edit:
Should I use the following commad to get sourcode binary from step (3) folder dnatool ?
$ tar -zcvf dnatool.tar.gz/home/dnatool
Upvotes: 2
Views: 2412
Reputation: 60924
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.
Upvotes: 2