Should I make my R developments a package? [closed] - r

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am developing a set of R scripts to post-process experimental data.
Currently, these are just scripts that I load individually by manually sourcing them.
I wonder if it would be better to put all those scripts in an R package, but as I constantly add/modify my library functions, I don't really know if this is the recommended way of doing it.
So my question is: should I go on working on "independent" script files or package them?

It is always good to bundle your scripts into a package. which will help you in lot many ways.
All your project fundamentals will be packed together
code portability will be lot easier
you can have test cases for your function using testthat package
You can have proper documentation for your code using roxygen2 package, which will help the readers or other users of the code to understand mode about the code.
you don't have to load your data and functions manually, you just have to load your package by saying library(package_name)
for more details about "R package": http://r-pkgs.had.co.nz/

Related

how to load my own function automatically as R-package? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I built my own function and each time I need to run this function, I need to do that manulally. Is there any way that I can load it automatically as any R-package? Or can I build an R-package used only by me?
Would recommend Nate Days solution, but you could also use Rs save() and load()functions to do this. It works on all R-objects and stores them in a binay .rda-file. You can store multiple objects as well.
Try:
add <- function(x, y){return(x+y)}
save(add, file = 'add_function.rda')
Whenever you need your function, do:
load('add_function.rda')
And add() would be available in the parent environment.
There is a package called pkgmaker on CRAN that has a ton of tools and utilities for you to create your own packages. As an alternate option you might consider creating a functions.R script for you to store all of your personally created and often used functions. You can add the line source('functions.R', local=TRUE) to your programs, scripts or apps and your functions will be accessible to you. Thats how I handle the issue anyway. Cheers

How R Language works [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I was kind of wondering,how R language works internally when we type some command..
Say License()
As per my understanding,R language is made of packages,When we execute some command,it invokes the Right package,i was not able to find some documentation supporting this..
Research done from side:
1.closest i could get is below link
https://cran.r-project.org/doc/contrib/Paradis-rdebuts_en.pdf
2.I searched using "How R Language works internally",but i could not get any relevant results..
Below is how SQLServer executes a query from starting to end ,i am looking to see similar kind of documentation/any pointers for R
please let me know if you have any pointers
The notion that the R language is "made of packages" is inaccurate. It is made of commands, operators and functions, like other programming languages. Those commands are grouped into namespaces which comprise commands that belong to the same topic. A package provides a set of specific commands (and sometimes other objects, like sample data) grouped into a namespace. By loading a library (there are subtle semantic differences between a library and a package) the namespace of the package becomes available in the global environment, thereby making these commands directly accessible.
On the suggestion of #CapelliC here is a fully typed answer.
The internals of R are included in the document: https://cran.r-project.org/doc/manuals/r-release/R-ints.html
It is not an easy read, but covers all of the detail. My advice would be search the document if you have a specific query...

Proper Coding Techniques in R [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am writing an R code that has many different functions that eventually I will want to use all together on different data sets.
As I keep building functions it seems to be getting harder to keep track of everything in my script.
My question is, is it proper R coding to break functions into separate R Scripts or should it all be in one massive script?
Thank you for your help. This is my first time trying to code something this large!
-B
Yes, you can store your functions in multiple R scripts.
If you need to call them, you can use source().
For eg:
Say you have func1 , func2 saved in myfunc.R.
To call them,
source('myfunc.R')
#other codes
func1()
func2()
As to whether this approach is recommended, depends on your project requirements.
Alternatively, you can consider packaging them as recommended by Richard.

Best method to work in R program [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have planned to start my R program carrier now. I have understand the usage R but i have some doubts on the procedure to be implement in R. As a startup i am planing to retrieve data from google analytics and show it to frontend using R shiny. So which will be the good flow to fetch the data. Is it good to fetch the google analytic data using R and process it or it will be good to fetch the data using other languages like php or Java. Also R is good to fetch the data from database or its a good practice to fetch the data using other commonly used languages and process using R.
Sorry the question is little bit descriptive but i am expecting a help from you guys
Thanks,
Organize it in a package(http://r-pkgs.had.co.nz/).
See https://developers.google.com/analytics/solutions/r-google-analytics?hl=en .
The database question depends on exactly what you are using, but R has a lot of resources.

Does R Cookbook work with Rstudio? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
This is a very basic question, but since I am new to R and I am starting to learn it now, I am buying this book.
http://www.amazon.in/Cookbook-OReilly-Cookbooks-Paul-Teetor/dp/0596809158
Now, after reading the sampler available on the internet, I found out that all the examples are given in R but I use Rstudio. I just wanted to know that the same instructions and syntax will work in Rstudio as well, right?
Thanks!
Basically - yes. RStudio is (only) the IDE (Integrated development environment - http://en.wikipedia.org/wiki/Integrated_development_environment) for R.
Hovewer, R Cookbook is from 2011, so it's recipes depend on quite old R version. It's possible, that some of recipes won't work, not because of using RStudio, but because of using newer R version.

Resources