Re: [R] Storing user-defined R functions
Thanks to everyone for writing. A well-known phenomenon in mathematics, statistics and/or complex computing is that everything one already knows feels trivial and easy. It's as though one is permanently climbing a vertical cliff-face, while, if you look back from where you've come, you see a level plateau just a couple of inches lower than one's boots. I take statements about how easy it is to make packages with a pinch of salt---I'm sure it's easy when you already know how. I've been looking through http://127.0.0.1:31257/doc/manual/R-exts.html#Creating-R-packages http://127.0.0.1:31257/doc/manual/R-exts.html#Creating-R-packages with a mixture of bafflement and horror. Even to skim this document without understanding all that much of it would take me a couple of hours. To make my first package might take me a couple of days, or maybe longer. To follow David Scott's suggestion would take me 5 minutes max. And I have a huge workload with looming deadlines It might be different if there were a Dummies' guide to packages, allowing one to rapidly assemble a a few easy functions, and omitting all the optional features---a guide to the first steps up the cliff-face. If there is a Dummies' guide, I would be glad to hear of it. David -- View this message in context: http://r.789695.n4.nabble.com/Storing-user-defined-R-functions-tp3402983p3404751.html Sent from the R help mailing list archive at Nabble.com. __ 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] Storing user-defined R functions
On 11-03-25 4:05 AM, David.Epstein wrote: Thanks to everyone for writing. A well-known phenomenon in mathematics, statistics and/or complex computing is that everything one already knows feels trivial and easy. It's as though one is permanently climbing a vertical cliff-face, while, if you look back from where you've come, you see a level plateau just a couple of inches lower than one's boots. I take statements about how easy it is to make packages with a pinch of salt---I'm sure it's easy when you already know how. I've been looking through http://127.0.0.1:31257/doc/manual/R-exts.html#Creating-R-packages http://127.0.0.1:31257/doc/manual/R-exts.html#Creating-R-packages with a mixture of bafflement and horror. Even to skim this document without understanding all that much of it would take me a couple of hours. To make my first package might take me a couple of days, or maybe longer. To follow David Scott's suggestion would take me 5 minutes max. And I have a huge workload with looming deadlines It might be different if there were a Dummies' guide to packages, allowing one to rapidly assemble a a few easy functions, and omitting all the optional features---a guide to the first steps up the cliff-face. If there is a Dummies' guide, I would be glad to hear of it. Short version: see ?package.skeleton. Longer version: Look at one of the tutorials on the web. The big problem with this longer version is that there isn't any quality control; people can write instructions that become obsolete, and there aren't necessarily going to be any updates. Mine from 2008 still seems okay: http://www.statistik.uni-dortmund.de/useR-2008/slides/Murdoch.pdf, but you can probably find others too. 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.
[R] Storing user-defined R functions
Hello, I don't want to find out how to make packages unless that becomes necessary. Also, I don't want to clog up the computer memory with functions that I'm not using. (It would be great if someone in this forum would explain how memory is used when I type library(MASS) and then use only one function from MASS. Are all the many MASS functions then residing in memory, or only the one I called?) Is there some standard way of 1. storing the R functions that I define, each in a separate file in some standard directory, and then 2. calling one of these functions without having to include the path to the relevant directory? 3. If so, are there conventional places to keep such files, akin to /usr/local/bin in Unix? I'm thinking of a facility like Matlab's, when one has user-defined paths where Matlab will look for my Matlab functions. In my Matlab code, I don't need to hard-wire in the path of the storage directory, and I can make the function call as though my function is in the current directory. Thanks, David -- View this message in context: http://r.789695.n4.nabble.com/Storing-user-defined-R-functions-tp3402983p3402983.html Sent from the R help mailing list archive at Nabble.com. __ 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] Storing user-defined R functions
On Fri, Mar 25, 2011 at 5:11 AM, David.Epstein david.epst...@warwick.ac.uk wrote: Hello, I don't want to find out how to make packages unless that becomes necessary. Also, I don't want to clog up the computer memory with functions that I'm not using. (It would be great if someone in this forum would explain how memory is used when I type library(MASS) and then use only one function from MASS. Are all the many MASS functions then residing in memory, or only the one I called?) There is a lazy-loading system that loads functions and datasets only on demand. Not all packages use it, but MASS does. Is there some standard way of 1. storing the R functions that I define, each in a separate file in some standard directory, and then 2. calling one of these functions without having to include the path to the relevant directory? 3. If so, are there conventional places to keep such files, akin to /usr/local/bin in Unix? No. You really do want to learn to make packages. It isn't that hard. However, another possibility is to use save() to save a file containing all your functions and then use attach() to make these functions available. This works like making a package except that you don't get lazy-loading, you don't get documentation, and you don't get the package checks. -thomas -- Thomas Lumley Professor of Biostatistics University of Auckland __ 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] Storing user-defined R functions
On 25/03/11 09:08, Thomas Lumley wrote: On Fri, Mar 25, 2011 at 5:11 AM, David.Epstein david.epst...@warwick.ac.uk wrote: Hello, I don't want to find out how to make packages unless that becomes necessary. Also, I don't want to clog up the computer memory with functions that I'm not using. (It would be great if someone in this forum would explain how memory is used when I type library(MASS) and then use only one function from MASS. Are all the many MASS functions then residing in memory, or only the one I called?) There is a lazy-loading system that loads functions and datasets only on demand. Not all packages use it, but MASS does. Is there some standard way of 1. storing the R functions that I define, each in a separate file in some standard directory, and then 2. calling one of these functions without having to include the path to the relevant directory? 3. If so, are there conventional places to keep such files, akin to /usr/local/bin in Unix? No. You really do want to learn to make packages. It isn't that hard. However, another possibility is to use save() to save a file containing all your functions and then use attach() to make these functions available. This works like making a package except that you don't get lazy-loading, you don't get documentation, and you don't get the package checks. -thomas Another work around would involve defining a little function in your .Rprofile, as follows. Choose a location for your code. The function would take the name of the file, prepend the path to the directory where your code is located and then call source. Two or three lines would do it. Also, who knows, maybe Gabor has something clever in his batch files, he usually seems to. David Scott -- _ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142,NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 Director of Consulting, Department of Statistics __ 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] Storing user-defined R functions
On 11-03-24 4:08 PM, Thomas Lumley wrote: On Fri, Mar 25, 2011 at 5:11 AM, David.Epstein david.epst...@warwick.ac.uk wrote: Hello, I don't want to find out how to make packages unless that becomes necessary. Also, I don't want to clog up the computer memory with functions that I'm not using. (It would be great if someone in this forum would explain how memory is used when I type library(MASS) and then use only one function from MASS. Are all the many MASS functions then residing in memory, or only the one I called?) There is a lazy-loading system that loads functions and datasets only on demand. Not all packages use it, but MASS does. Is there some standard way of 1. storing the R functions that I define, each in a separate file in some standard directory, and then 2. calling one of these functions without having to include the path to the relevant directory? 3. If so, are there conventional places to keep such files, akin to /usr/local/bin in Unix? No. You really do want to learn to make packages. It isn't that hard. However, another possibility is to use save() to save a file containing all your functions and then use attach() to make these functions available. This works like making a package except that you don't get lazy-loading, you don't get documentation, and you don't get the package checks. ... and you don't get the standard layout and naming conventions so you have to invent your own, and nobody will want to share your code, and it will be much more difficult to integrate C or C++ or Fortran code. David *really* should use packages. 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.