How to create R Package using RStudio?

Part A: Create the package

1. Click File –> New Project…

image

2. Under “New Project” Dialog, Click “New Dirctory

image

 

3. Click “R Package

image

 

4. Profide a “Pakage name

5. Add your files which you want to be packaged.

6. May specify a path where you want this package to be created.

image

7. Click “Create Project

Have a look at this area of RStudio. May do any manipulations, like additing package dependencies.

image

Now, click menu Build –> “Build and Reload

image

You can see it is building:

image

Test your library. The sample R file which I used had only one function called TestFunction()

image

8. Next, you can package it. Click Build –> “Build Binary Package

image

You can go to the folder spcified initially to see the ZIP file created.

image

Part B: Install the package

1. Choose “Install from:”Package Archieve File

2. Choose the “Package archive” by clicking “Browse…” button

3. Click “Install

image

Ta-da…

image

Happy R Packaging!

 

Change missing values in Data Frame to NA in R