Dear all, I am a new user of R and currently trying hard to develop my own package. Here I am following this tutorial 'http://www.mathfinance.cn/how-to-create-an-R-package-in-windows/' Here it says that (step 8): "open a ?command prompt? window, change the directory to where your package is, type the command ?R CMD build MonteCarloPi? to build the package, this will generate a file called MonteCarloPi_1.0.tar.gz. " According to that, I have opened the Windows command prompt window (a black screen window) and then changed the directory, where my new package (a folder in current working directory in R, as created by 'package.skeleton') is there. Then typed 'R CMD build MyPackage' (I named my package as 'MyPackage'). However doing so I got following error in that command prompt: 'R' is not recognized as an internal or external command, operable program or batch file. Can somebody please guide me what to do in this situation? Best thanks
Seeking help in Package development
10 messages · Gabor Grothendieck, Nipesh Bajaj, Joshua Wiley +2 more
On Sat, Feb 19, 2011 at 4:39 PM, Nipesh Bajaj <bajaj141003 at gmail.com> wrote:
Dear all, I am a new user of R and currently trying hard to develop my own package. Here I am following this tutorial 'http://www.mathfinance.cn/how-to-create-an-R-package-in-windows/' Here it says that (step 8): "open a ?command prompt? window, change the directory to where your package is, type the command ?R CMD build MonteCarloPi? to build the package, this will generate a file called MonteCarloPi_1.0.tar.gz. " According to that, I have opened the Windows command prompt window (a black screen window) and then changed the directory, where my new package (a folder in current working directory in R, as created by 'package.skeleton') is there. Then typed 'R CMD build MyPackage' (I named my package as 'MyPackage'). However doing so I got following error in that command prompt: 'R' is not recognized as an internal or external command, operable program or batch file. Can somebody please guide me what to do in this situation?
You have to modify you path, adding the directory containing R.exe so that Windows can find R. Alternately you can download R.bat from batchfiles.googlecode.com and place it anywhere on your path to avoid having to modify your path itself. It will find R from the registry and run it with the same arguments.
Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
Dear Nipesh,
On Sat, Feb 19, 2011 at 1:39 PM, Nipesh Bajaj <bajaj141003 at gmail.com> wrote:
Dear all, I am a new user of R and currently trying hard to develop my own package. Here I am following this tutorial 'http://www.mathfinance.cn/how-to-create-an-R-package-in-windows/' Here it says that (step 8): "open a ?command prompt? window, change the directory to where your package is, type the command ?R CMD build MonteCarloPi? to build the package, this will generate a file called MonteCarloPi_1.0.tar.gz. " According to that, I have opened the Windows command prompt window (a black screen window) and then changed the directory, where my new package (a folder in current working directory in R, as created by 'package.skeleton') is there. Then typed 'R CMD build MyPackage' (I named my package as 'MyPackage'). However doing so I got following error in that command prompt: 'R' is not recognized as an internal or external command, operable program or batch file.
This suggests that either your current directory does not contain R and you have not added the directory containing R to the PATH environment variable in Windows. For that command to work, Windows needs to know where to find the program to execute. You might find this site useful for becoming more familiar with the Windows command prompt (geared towards XP, but cmd.exe has changed little from XP to Vista, to 7---though increasing MS is encouraging users to switch over to using the Windows powershell): http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true
Can somebody please guide me what to do in this situation?
You should also read the official R manual on installing and building R from source. Particularly pay attention to the sections for Windows users. You may want to get Rtools and certainly follow the instructions to add all the necessary directories to your PATH variable. The steps will be something like: Right click My Computer -> Click Properties -> Click Advanced -> Click Environment Variables -> edit the variable "PATH" to include relevant R directories. Please note that this is not an exact step-by-step process as it varies slightly by different versions of Windows. Official R Installation Manual (very relevant for building packages): http://cran.r-project.org/doc/manuals/R-admin.html Good luck, Josh
Best thanks
______________________________________________ R-help at 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.
Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/
Thanks Gabor for your input. Here what I have done is that:
1. Copy 'MyPackage' folder (developed by package.skeleton) into
'C:\Program Files\R\R-2.12.1\bin' (I found R.exe is there)
2. In the command prompt, I changed the working directory using "CD"
command and run 'R CMD build MyPackage'
3. I have seen that a file named 'MyPackage_1.0.tar' has been created.
Then I pasted that file in ''C:\Program Files\R\R-2.12.1\bin'
4. Again run R CMD INSTALL MyPackage_1.0.tar.gz. However here I got
some error saying:
'Error in Rd_info(db[[i]]) : Rd files must have a non-empty \title'
In my Package, there are 2 user defined functions MyFunction1 &
MyFunction2, 1st function just get the length of it's argument and 2nd
function get the Range. I have modified the manual pages of those 2
functions as (just 1st few lines):
\name{MyFunction1}
\alias{MyFunction1}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
~~(Title) This function try to get the length of it's arguments ~~
}
\description{
~~ (Description) This function try to get the length of it's arguments ~~
}
\usage{
MyFunction1(x)
}
\name{MyFunction2}
\alias{MyFunction2}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
~~(Title) This function try to get the range of it's arguments ~~
}
\description{
%% ~~ A concise (1-5 lines) description of what the function does. ~~
}
\usage{
MyFunction2(x)
}
I understand there is something to do with the 'title' segments of any
(or all) those 2 functions. However could not find what to do. Any
point please?
Actually I wanted to create .zip file as I am working in Vista. For
that I have intalled R_tool as well. However I could not understand
how I can use that. Any help will be highly appreciated.
Thanks,
On Sun, Feb 20, 2011 at 3:22 AM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
On Sat, Feb 19, 2011 at 4:39 PM, Nipesh Bajaj <bajaj141003 at gmail.com> wrote:
Dear all, I am a new user of R and currently trying hard to develop my own package. Here I am following this tutorial 'http://www.mathfinance.cn/how-to-create-an-R-package-in-windows/' Here it says that (step 8): "open a ?command prompt? window, change the directory to where your package is, type the command ?R CMD build MonteCarloPi? to build the package, this will generate a file called MonteCarloPi_1.0.tar.gz. " According to that, I have opened the Windows command prompt window (a black screen window) and then changed the directory, where my new package (a folder in current working directory in R, as created by 'package.skeleton') is there. Then typed 'R CMD build MyPackage' (I named my package as 'MyPackage'). However doing so I got following error in that command prompt: 'R' is not recognized as an internal or external command, operable program or batch file. Can somebody please guide me what to do in this situation?
You have to modify you path, adding the directory containing R.exe so that Windows can find R. Alternately you can download R.bat from batchfiles.googlecode.com and place it anywhere on your path to avoid having to modify your path itself. ?It will find R from the registry and run it with the same arguments. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
On Sat, Feb 19, 2011 at 5:31 PM, Nipesh Bajaj <bajaj141003 at gmail.com> wrote:
Thanks Gabor for your input. Here what I have done is that: 1. Copy 'MyPackage' folder (developed by package.skeleton) into 'C:\Program Files\R\R-2.12.1\bin' (I found R.exe is there) 2. In the command prompt, I changed the working directory using "CD" command and run 'R CMD build MyPackage' 3. I have seen that a file named 'MyPackage_1.0.tar' has been created. Then I pasted that file in ''C:\Program Files\R\R-2.12.1\bin' 4. Again run R CMD INSTALL MyPackage_1.0.tar.gz. However here I got some error saying: 'Error in Rd_info(db[[i]]) : Rd files must have a non-empty \title'
What you have done in #1 is asking for trouble. You do need to get used to debugging your Rd files and you should expect to get many warnings and errors. Read the messages carefully and keep correcting them and rebuilding and checking until they pass.
Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
Hi Gabor, can you be more detail on step 01? Is that not the correct path for R.exe? But I found it there. When I ran R CMD build MyPackage then actually got these warnings: cygwin warnings: MS-DOS style path detected: c:/Program Files/R/R-2.12.1/bin/Mypackage_1.0.tar prefered POSIX equivalent is /cygdrive/c/Program Files/R/R-2.12.1/bin/MyPackage_1.0.tar CYGWIN environment variable option "nodesfilewarning" turns off this warning............. Is this warning something to do with that error? Sorry for stretching this thread so long. However I am not really expert in programming therefore find really hard on understanding different terminology given in different documentation. Thanks, On Sun, Feb 20, 2011 at 4:35 AM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
On Sat, Feb 19, 2011 at 5:31 PM, Nipesh Bajaj <bajaj141003 at gmail.com> wrote:
Thanks Gabor for your input. Here what I have done is that: 1. Copy 'MyPackage' folder (developed by package.skeleton) into 'C:\Program Files\R\R-2.12.1\bin' (I found R.exe is there) 2. In the command prompt, I changed the working directory using "CD" command and run 'R CMD build MyPackage' 3. I have seen that a file named 'MyPackage_1.0.tar' has been created. Then I pasted that file in ''C:\Program Files\R\R-2.12.1\bin' 4. Again run R CMD INSTALL MyPackage_1.0.tar.gz. However here I got some error saying: 'Error in Rd_info(db[[i]]) : Rd files must have a non-empty \title'
What you have done in #1 is asking for trouble. You do need to get used to debugging your Rd files and you should expect to get many warnings and errors. ?Read the messages carefully and keep correcting them and rebuilding and checking until they pass. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
On Sat, Feb 19, 2011 at 6:19 PM, Nipesh Bajaj <bajaj141003 at gmail.com> wrote:
Hi Gabor, can you be more detail on step 01? Is that not the correct path for R.exe? But I found it there. When I ran R CMD build MyPackage then actually got these warnings: cygwin warnings: MS-DOS style path detected: c:/Program Files/R/R-2.12.1/bin/Mypackage_1.0.tar prefered POSIX equivalent is /cygdrive/c/Program Files/R/R-2.12.1/bin/MyPackage_1.0.tar CYGWIN environment variable option "nodesfilewarning" turns off this warning............. Is this warning something to do with that error? Sorry for stretching this thread so long. However I am not really expert in programming therefore find really hard on understanding different terminology given in different documentation. Thanks,
Don't put your package in the R tree. You can ignore those warnings. If you had used R.bat then as in my original instructions you wouldn't have gotten those warnings in the first place.
Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
Hi Nipesh, Although "c:/Program Files/R/R-2.12.1/bin/" may be where R.exe is located, it is not where you want to locate your package, and, as Gabor pointed out, it is best to keep your package outside of the main R tree. Your package does not need to be in the same location as R.exe, you just need the command prompt to know where R.exe is. If R.exe is located in location A and your package is in location B, at the command prompt you can change directories to A, and then tell it to build the package found in B. Alternately (again as I mentioned), you can setyour PATH environment variable to include R's directory, then it will be found automatically no matter what your current directory is. The cygwin warnings are okay in this case. Unless you urgently need to develop your own package, it might be easier to learn more about programming in R first and then try creating a package. The references I sent in my earlier email would be good; I also found Software for Data Analysis: Programming with R by John Chambers to be a very useful resource---I have read most of it twice now and each time I feel like I have picked up on details or nuances I missed the first time through. It is also relatively inexpensive. Another helpful book is S Programming by Venables and Ripley. You might also consider searching the archives of the R-devel mailing list. Although much of it will not be relevant to general package development, there is a lot you can learn from reading what the people there discuss. Cheers, Josh
On Sat, Feb 19, 2011 at 3:19 PM, Nipesh Bajaj <bajaj141003 at gmail.com> wrote:
Hi Gabor, can you be more detail on step 01? Is that not the correct path for R.exe? But I found it there. When I ran R CMD build MyPackage then actually got these warnings: cygwin warnings: MS-DOS style path detected: c:/Program Files/R/R-2.12.1/bin/Mypackage_1.0.tar prefered POSIX equivalent is /cygdrive/c/Program Files/R/R-2.12.1/bin/MyPackage_1.0.tar CYGWIN environment variable option "nodesfilewarning" turns off this warning............. Is this warning something to do with that error? Sorry for stretching this thread so long. However I am not really expert in programming therefore find really hard on understanding different terminology given in different documentation. Thanks, On Sun, Feb 20, 2011 at 4:35 AM, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
On Sat, Feb 19, 2011 at 5:31 PM, Nipesh Bajaj <bajaj141003 at gmail.com> wrote:
Thanks Gabor for your input. Here what I have done is that: 1. Copy 'MyPackage' folder (developed by package.skeleton) into 'C:\Program Files\R\R-2.12.1\bin' (I found R.exe is there) 2. In the command prompt, I changed the working directory using "CD" command and run 'R CMD build MyPackage' 3. I have seen that a file named 'MyPackage_1.0.tar' has been created. Then I pasted that file in ''C:\Program Files\R\R-2.12.1\bin' 4. Again run R CMD INSTALL MyPackage_1.0.tar.gz. However here I got some error saying: 'Error in Rd_info(db[[i]]) : Rd files must have a non-empty \title'
What you have done in #1 is asking for trouble. You do need to get used to debugging your Rd files and you should expect to get many warnings and errors. ?Read the messages carefully and keep correcting them and rebuilding and checking until they pass. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
______________________________________________ R-help at 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.
Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/
May I add that the best documentation for building packages is the "Writing R Extensions" that ships with the current R version. It is always current, precise, and not as outdated as many resources you find "somewhere" in the web - yes, the one cited below is outdated. Uwe Ligges
On 19.02.2011 22:59, Joshua Wiley wrote:
Dear Nipesh, On Sat, Feb 19, 2011 at 1:39 PM, Nipesh Bajaj<bajaj141003 at gmail.com> wrote:
Dear all, I am a new user of R and currently trying hard to develop my own package. Here I am following this tutorial 'http://www.mathfinance.cn/how-to-create-an-R-package-in-windows/' Here it says that (step 8): "open a ?command prompt? window, change the directory to where your package is, type the command ?R CMD build MonteCarloPi? to build the package, this will generate a file called MonteCarloPi_1.0.tar.gz. " According to that, I have opened the Windows command prompt window (a black screen window) and then changed the directory, where my new package (a folder in current working directory in R, as created by 'package.skeleton') is there. Then typed 'R CMD build MyPackage' (I named my package as 'MyPackage'). However doing so I got following error in that command prompt: 'R' is not recognized as an internal or external command, operable program or batch file.
This suggests that either your current directory does not contain R and you have not added the directory containing R to the PATH environment variable in Windows. For that command to work, Windows needs to know where to find the program to execute. You might find this site useful for becoming more familiar with the Windows command prompt (geared towards XP, but cmd.exe has changed little from XP to Vista, to 7---though increasing MS is encouraging users to switch over to using the Windows powershell): http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true
Can somebody please guide me what to do in this situation?
You should also read the official R manual on installing and building R from source. Particularly pay attention to the sections for Windows users. You may want to get Rtools and certainly follow the instructions to add all the necessary directories to your PATH variable. The steps will be something like: Right click My Computer -> Click Properties -> Click Advanced -> Click Environment Variables -> edit the variable "PATH" to include relevant R directories. Please note that this is not an exact step-by-step process as it varies slightly by different versions of Windows. Official R Installation Manual (very relevant for building packages): http://cran.r-project.org/doc/manuals/R-admin.html Good luck, Josh
Best thanks
______________________________________________ R-help at 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.
----------------------------------------
Date: Sun, 20 Feb 2011 15:56:41 +0100 From: ligges at statistik.tu-dortmund.de To: jwiley.psych at gmail.com CC: r-help at r-project.org Subject: Re: [R] Seeking help in Package development May I add that the best documentation for building packages is the "Writing R Extensions" that ships with the current R version. It is always current, precise, and not as outdated as many resources you find "somewhere" in the web - yes, the one cited below is outdated. Uwe Ligges On 19.02.2011 22:59, Joshua Wiley wrote:
Dear Nipesh, On Sat, Feb 19, 2011 at 1:39 PM, Nipesh Bajaj wrote:
Dear all, I am a new user of R and currently trying hard to develop my own package. Here I am following this tutorial 'http://www.mathfinance.cn/how-to-create-an-R-package-in-windows/' Here it says that (step 8): "open a ?command prompt? window, change the directory to where your package is, type the command ?R CMD build MonteCarloPi? to build the package, this will generate a file called MonteCarloPi_1.0.tar.gz. "
a
black screen window) and then changed the directory, where my new package (a folder in current working directory in R, as created by 'package.skeleton') is there. Then typed 'R CMD build MyPackage' (I named my package as 'MyPackage'). However doing so I got following error in that command prompt: 'R' is not recognized as an internal or external command, operable program or batch file.
This suggests that either your current directory does not contain R and you have not added the directory containing R to the PATH
needs to know where to find the program to execute. You might find
prompt (geared towards XP, but cmd.exe has changed little from XP to Vista, to 7---though increasing MS is encouraging users to switch over
Can somebody please guide me what to do in this situation?
I guess if you are shopping for alternative shells, consider cygwin and then you get all the power of years of other developer's work. I am not sure what MSFT is doing with a "powershell" but very good open tools already exist for linux that cygwin allows you to use here. I have had a few issues with latest cygwin on Doh's 7 but probably due to install problems. I routinely use R with cygwin and have never used a GUI wth R? except for a popup on debian version. You will even find, if you learn the linux tools, that R makes a lot more sense. I just started to play with package building, didn't complete one yet, and everything pretty much made sense right away on debian.
You should also read the official R manual on installing and building
users. You may want to get Rtools and certainly follow the instructions to add all the necessary directories to your PATH variable. The steps will be something like: Right click My Computer -> Click Properties -> Click Advanced -> Click Environment Variables -> edit the variable "PATH" to include relevant R directories. Please note that this is not an exact step-by-step
Official R Installation Manual (very relevant for building packages): http://cran.r-project.org/doc/manuals/R-admin.html Good luck, Josh
Best thanks
______________________________________________ R-help at 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.
______________________________________________ R-help at 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.