Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a package in R using RStudio

Tags:

package

r

rstudio

I've created a bunch of files:

  • init.r
  • auth.r
  • class.r
  • modules/status.r
  • modules/mgmt.r
  • modules/core.r
  • modules/mcf.r

The source of the init.r file is:

# initiation of package

# include libraries
library(RCurl);
library(rjson);

# include files
source('auth.r');
source('class.r');

# extend class
source('modules/status.r');
source('modules/mgmt.r');
source('modules/core.r');
source('modules/mcf.r');

How do I go about creating a package out of this? The init.r file obviously needs to be initiated first.

like image 833
bskard Avatar asked Nov 15 '12 14:11

bskard


2 Answers

Start with following the steps in this video:

Build an R Package in under 2 minutes with RStudio

Then read more about RStudio's Package Development feature, and also Hadley Wickam's Package basics.

like image 189
Jeff Avatar answered Sep 28 '22 06:09

Jeff


See Writing R Extensions for the process of making a package. You might want to use package.skeleton to get started.

But essentially,

  • get rid of your init.r file,
  • put all your other .R files in the R directory
  • write Depends: RCurl, rjson in your DESCRIPTION file.
like image 32
Romain Francois Avatar answered Sep 28 '22 06:09

Romain Francois