Re: [R] What is the most efficient practice to develop an R package?
On 10/26/2009 10:29 AM, Peng Yu wrote: I am reading Section 5 and 6 of http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf It seems that I have to do the following two steps in order to make an R package. But when I am testing these package, these two steps will run many times, which may take a lot of time. So when I still develop the package, shall I always source('linmod.R') to test it. Once the code in linmod.R is finalized, then I run the following two steps? I'm wondering what people usually do when developing packages. 1. Run the following command in R to create the package package.skeleton(name=linmod, code_files=linmod.R) 2. Run the following command in shell to install R CMD INSTALL -l /path/to/library linmod You only do step 1 once, and you missed step 1.5: edit the files, which comes before step 2. I usually cycle between steps 1.5 and 2 multiple times. Sometimes I will not repeat step 2, I'll put together a small script that includes source('linmod.R') environment(somefunction) - environment(linmod::somefunction) and source that instead. The second line makes somefunction look for functions in the namespace of the package; it's only useful if my edits only affect one function, and the functions in the package never call it: so usually I do the full install. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What is the most efficient practice to develop an R package?
Peng Yu wrote: I am reading Section 5 and 6 of http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf It seems that I have to do the following two steps in order to make an R package. But when I am testing these package, these two steps will run many times, which may take a lot of time. So when I still develop the package, shall I always source('linmod.R') to test it. Once the code in linmod.R is finalized, then I run the following two steps? I'm wondering what people usually do when developing packages. 1. Run the following command in R to create the package package.skeleton(name=linmod, code_files=linmod.R) Do this once, to get a skeleton. Then edit the R source etc in the created package. 2. Run the following command in shell to install R CMD INSTALL -l /path/to/library linmod see R CMD INSTALL --help and use options that minimize the amount of non-essential work, e.g., no vignettes or documentation until that is the focus of your development, or --libs-only if you are working on C code. Use --clean to avoid stale package components. Develop individual functions interactively, but write a script library(MyPackage) someFunction() so that R -f myscript.R allows you to easily load your package and test specific functionality in a clean R session. Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What is the most efficient practice to develop an R package?
On 26 October 2009 at 07:57, Martin Morgan wrote: | Peng Yu wrote: | I am reading Section 5 and 6 of | http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf | | It seems that I have to do the following two steps in order to make an | R package. But when I am testing these package, these two steps will | run many times, which may take a lot of time. So when I still develop | the package, shall I always source('linmod.R') to test it. Once the | code in linmod.R is finalized, then I run the following two steps? | | I'm wondering what people usually do when developing packages. | | | 1. Run the following command in R to create the package | package.skeleton(name=linmod, code_files=linmod.R) | | Do this once, to get a skeleton. Then edit the R source etc in the | created package. | | 2. Run the following command in shell to install | R CMD INSTALL -l /path/to/library linmod | | see R CMD INSTALL --help and use options that minimize the amount of | non-essential work, e.g., no vignettes or documentation until that is | the focus of your development, or --libs-only if you are working on C | code. Use --clean to avoid stale package components. Develop individual | functions interactively, but write a script | | library(MyPackage) | someFunction() | | so that R -f myscript.R allows you to easily load your package and test | specific functionality in a clean R session. With littler you can do without the one-off script as $ r -lMyPackage -e'print(someFunction())' runs both commands you would have put into script. Hence, I often do something like $ R CMD INSTALL MyPackage/ r -lMyPackage -e'print(someFunction())' Dirk -- Three out of two people have difficulties with fractions. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What is the most efficient practice to develop an R package?
On Mon, Oct 26, 2009 at 11:22 AM, Dirk Eddelbuettel e...@debian.org wrote: On 26 October 2009 at 07:57, Martin Morgan wrote: | Peng Yu wrote: | I am reading Section 5 and 6 of | http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf | | It seems that I have to do the following two steps in order to make an | R package. But when I am testing these package, these two steps will | run many times, which may take a lot of time. So when I still develop | the package, shall I always source('linmod.R') to test it. Once the | code in linmod.R is finalized, then I run the following two steps? | | I'm wondering what people usually do when developing packages. | | | 1. Run the following command in R to create the package | package.skeleton(name=linmod, code_files=linmod.R) | | Do this once, to get a skeleton. Then edit the R source etc in the | created package. | | 2. Run the following command in shell to install | R CMD INSTALL -l /path/to/library linmod | | see R CMD INSTALL --help and use options that minimize the amount of | non-essential work, e.g., no vignettes or documentation until that is | the focus of your development, or --libs-only if you are working on C | code. Use --clean to avoid stale package components. Develop individual | functions interactively, but write a script | | library(MyPackage) | someFunction() | | so that R -f myscript.R allows you to easily load your package and test | specific functionality in a clean R session. With littler you can do without the one-off script as $ r -lMyPackage -e'print(someFunction())' runs both commands you would have put into script. Hence, I often do something like $ R CMD INSTALL MyPackage/ r -lMyPackage -e'print(someFunction())' What does the small case 'r' do? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What is the most efficient practice to develop an R package?
On 26 October 2009 at 13:29, Peng Yu wrote: | On Mon, Oct 26, 2009 at 11:22 AM, Dirk Eddelbuettel e...@debian.org wrote: | | On 26 October 2009 at 07:57, Martin Morgan wrote: | | Peng Yu wrote: | | I am reading Section 5 and 6 of | | http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf | | | | It seems that I have to do the following two steps in order to make an | | R package. But when I am testing these package, these two steps will | | run many times, which may take a lot of time. So when I still develop | | the package, shall I always source('linmod.R') to test it. Once the | | code in linmod.R is finalized, then I run the following two steps? | | | | I'm wondering what people usually do when developing packages. | | | | | | 1. Run the following command in R to create the package | | package.skeleton(name=linmod, code_files=linmod.R) | | | | Do this once, to get a skeleton. Then edit the R source etc in the | | created package. | | | | 2. Run the following command in shell to install | | R CMD INSTALL -l /path/to/library linmod | | | | see R CMD INSTALL --help and use options that minimize the amount of | | non-essential work, e.g., no vignettes or documentation until that is | | the focus of your development, or --libs-only if you are working on C | | code. Use --clean to avoid stale package components. Develop individual | | functions interactively, but write a script | | | | library(MyPackage) | | someFunction() | | | | so that R -f myscript.R allows you to easily load your package and test | | specific functionality in a clean R session. | | With littler you can do without the one-off script as | | $ r -lMyPackage -e'print(someFunction())' | | runs both commands you would have put into script. Hence, I often do | something like | | $ R CMD INSTALL MyPackage/ r -lMyPackage -e'print(someFunction())' | | What does the small case 'r' do? It is a scripting front-end to R and useful for e.g. writing scripts with a so-called shebang line (i.e #!/usr/bin/r in the first line), or for quickly evaluating command-line expression as I showed you here, or running R scripts instead of calling R followed by source() --- see the web page at http://dirk.eddelbuettel.com/code/littler.html for more. Litter (aka 'r') is similar to Rscript which came a few months later, starts a little slower but runs on more platforms. Dirk -- Three out of two people have difficulties with fractions. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What is the most efficient practice to develop an R package?
Dirk Eddelbuettel wrote: On 26 October 2009 at 13:29, Peng Yu wrote: | On Mon, Oct 26, 2009 at 11:22 AM, Dirk Eddelbuettel e...@debian.org wrote: | | On 26 October 2009 at 07:57, Martin Morgan wrote: | | Peng Yu wrote: | | I am reading Section 5 and 6 of | | http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf | | | | It seems that I have to do the following two steps in order to make an | | R package. But when I am testing these package, these two steps will | | run many times, which may take a lot of time. So when I still develop | | the package, shall I always source('linmod.R') to test it. Once the | | code in linmod.R is finalized, then I run the following two steps? | | | | I'm wondering what people usually do when developing packages. | | | | | | 1. Run the following command in R to create the package | | package.skeleton(name=linmod, code_files=linmod.R) | | | | Do this once, to get a skeleton. Then edit the R source etc in the | | created package. | | | | 2. Run the following command in shell to install | | R CMD INSTALL -l /path/to/library linmod | | | | see R CMD INSTALL --help and use options that minimize the amount of | | non-essential work, e.g., no vignettes or documentation until that is | | the focus of your development, or --libs-only if you are working on C | | code. Use --clean to avoid stale package components. Develop individual | | functions interactively, but write a script | | | | library(MyPackage) | | someFunction() | | | | so that R -f myscript.R allows you to easily load your package and test | | specific functionality in a clean R session. | | With littler you can do without the one-off script as | | $ r -lMyPackage -e'print(someFunction())' | | runs both commands you would have put into script. Hence, I often do | something like | | $ R CMD INSTALL MyPackage/ r -lMyPackage -e'print(someFunction())' | | What does the small case 'r' do? It is a scripting front-end to R and useful for e.g. writing scripts with a so-called shebang line (i.e #!/usr/bin/r in the first line), or for quickly evaluating command-line expression as I showed you here, or running R scripts instead of calling R followed by source() --- see the web page at http://dirk.eddelbuettel.com/code/littler.html for more. Litter (aka 'r') is similar to Rscript which came a few months later, starts a little slower but runs on more platforms. and for the record R -e library(MyPackage); someFunction() though probably a better practice is to add --vanilla (or --quiet or --slave) too. Martin Dirk -- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.