I have never done it, but want to develop R package for domestic use:
For example following are my functions and a data:
# 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")
I tried to use utils package to develop framework, but had a problem:
require(utils)
package.skeleton(list = c("randDNA","dna2rna", "compSeq", "myseqdata"),
name = "dnatool",environment = .GlobalEnv, path = "c:", force = FALSE)
Creating directories ...
Creating DESCRIPTION ...
Creating Read-and-delete-me ...
Saving functions and data ...
Making help files ...
Error in .find.package(pkgName, lib.loc, verbose = verbose) :
there is no package called 'dnatool'
Error in package.skeleton(list = c("randDNA", "dna2rna", "compSeq", "myseqdata"), :
Error in .find.package(pkgName, lib.loc, verbose = verbose) :
there is no package called 'dnatool'
I have question regarding why I am getting this error. When I looked at C:\dnatool I can see the folder created with the data and r functions.
Now I want to compile to make it as package. As I am reading instructions, I used command prompt to pack it: I am using Windows 7.
c:\> R CMD build dnatool
Obviously does not work. Is that due to above problem? What path should I be in? Where there is R exe or C: or c:\dnatool
I will appreciate your help, if you can in R "layman" style help...thanks...
EDITS: I downloaded Rtools Rtools212.exe for R version 2.12.2 from: http://www.murdoch-sutherland.com/Rtools/ The tools are installed in C:\Rtools
Directory of c:\Rtools
09/18/2011 08:08 AM <DIR> .
09/18/2011 08:08 AM <DIR> ..
09/18/2011 08:07 AM <DIR> bin
03/31/2010 09:50 AM 18,347 COPYING
09/18/2011 08:08 AM <DI开发者_开发知识库R> MinGW
09/18/2011 08:09 AM <DIR> MinGW64
10/04/2010 10:21 AM 1,836 README.txt
10/07/2010 08:26 AM 3,676 Rtools.txt
09/18/2011 08:10 AM 728,889 unins000.dat
09/18/2011 08:07 AM 1,182,143 unins000.exe
5 File(s) 1,934,891 bytes
5 Dir(s) 36,454,875,136 bytes free
My skeleton of the package is in C:\dnatool:
Directory of c:\dnatool
09/17/2011 11:14 PM <DIR> .
09/17/2011 11:14 PM <DIR> ..
09/17/2011 11:14 PM <DIR> data
09/17/2011 11:14 PM 304 DESCRIPTION
09/17/2011 11:14 PM <DIR> man
09/17/2011 11:14 PM <DIR> R
09/17/2011 11:14 PM 385 Read-and-delete-me
2 File(s) 689 bytes
5 Dir(s) 36,455,153,664 bytes free
My R program is C:\R....
My confusion is on the following instructions: where should execute them? I believe in command prompt. Under which directory?
* Run R CMD build to build the package tarball.
* Run R CMD check to check the package tarball.
************Edits2: partial solution but with new error ****************************** The first round of problem has been solved with the suggestion for path. I have to manually change the path to:
C:\Rtools\bin;C:\Rtools\perl\bin;C:\Rtools\MinGW\bin;
C:\Program files\R\R-2.12.2\bin\x64;
I stored the skeleton to new directory. By running the following command in command prompt:
C:\Users\Owner\Documents\rpackages> Rcmd INSTALL --build dnatool
* installing to library 'C:/PROGRA~1/R/R-212~1.2/library'
* installing *source* package 'dnatool' ...
** R
** data
** preparing package for lazy loading
** help
Warning: C:/Users/Owner/Documents/rpackages/dnatool/man/dnatool-package.Rd:34: A
ll text must be in a section
Warning: C:/Users/Owner/Documents/rpackages/dnatool/man/dnatool-package.Rd:35: A
ll text must be in a section
*** installing help indices
Error in Rd_info(db[[i]]) : Rd files must have a non-empty \title.
See chapter 'Writing R documentation' in manual 'Writing R Extensions'.
* removing 'C:/PROGRA~1/R/R-212~1.2/library/dnatool
I was unsuccessful to create the package, the see the error in above window. What does this mean. I added relevent information line 34 and 35 of the file dnatool-package .Rd ...help ...thanks...
I am answering my question myself, so that it will remain unanswered, if fact partially it is. With the suggestions here , the problem has been solved by changing path by setting the following:
C:\Rtools\bin;C:\Rtools\perl\bin;C:\Rtools\MinGW\bin;
C:\Program files\R\R-2.12.2\bin\x64;
I stored the skeleton to new directory.
By running the following command in command prompt:
C:\Users\Owner\Documents\rpackages> Rcmd INSTALL --build dnatool
精彩评论