# How to Submit Your R package to CRAN!

After two days of tireless submission, I finally received the passed reply at noon today!

## The process of submission

I’ve tried to write a lot messy R packages, all left on my GitHub @czxa. These R packages are so unstable that they can’t be installed on other people’s computer. In recently months, I have tried to rewrite them, but I haven’t done it yet. An important part of this work if translate all Chinese into English(really tired, feeling like work for foreigners).

The ‘hwordcloud’ package was build based on ‘htmlwidgets’ . By binding ‘Highcharts’ charting library, hwordcloud provides a simple way to draw word clouds in R. Notice that Highcharts is a commerical JavaScript charting library, which offers both a commerical license as well as free non-commerical license. Please review the licensing options and terms before using this software, as this package license neither provides nor implies a license for Highcharts.

As my first submission on CRAN, I feel so excited that I couldn’t wait to write down this blog to share my experience and lessons in the process of submission.

I developed the R Package using RStudio.

Note 1: Don’t use Chinese in R packages.

Chinese may be considered as ‘non-ASCII’ characters. This means your packages can’t be installed on Windows OS.

After your packages is written, it can be checked by RStudio.

Before checking, Configure the building tool. Fill Check Package - R CMD check additional options with --as-cran, which means to check in accordance with CRAN requirements. Then click ‘OK’.

Come back to the main panel of RStudio, click Check to check your R package, The best result is 0 errors ✔ | 0 warnings ✔ | 0 notes ✔. Errors are unacceptable. If there are any errors. I’m sure it can’t pass CRAN’s pre-check.

No errors in the result of the check doesn’t mean that it’s truly no problem. Further check need to be carried out next.

Next, Build Source Package. It can be operated on interface or use the following commands:

The last line of results tells you where ‘hwordcloud_0.1.0.tar.gz’ is.

The result is:

This is a warning result, it was because I just submitted version 0.1.0. However, before this submission, the result is a NOTE message.

This check also generates a folder named hwordcloud.Rcheck. There is a hwordcloud-manual.pdf in it, which is your package document. If you use Chinese in your Packages, the compilation of this PDF document will fail. There is also a 00check.log file it, which is a log file. You can find detailed errors, warnings and notes of the check.

Next, Submit the package source to CRAN: https://cran.r-project.org/submit.html

Submit step by step:

After finishing step 3, you will receive a email from CRAN in 10 minutes to six hours, this email is to let you confirm your submission.

Continue to wait. Next, CRAN will run a pre-check on your submitted packages. This pre-check is more stringent than the check just made at our terminal, mainly checking iterms in Description file. It should be noted that:

1. The title iterm should be in title-format, for example: Rendering Word Clouds;
2. The Description should contains more than one sentence, without any spelling errors. Package names, software names and API names should be enclosed in single quotation marks, just like the response I received:

Please write package names, software names and API names in single quotes (e.g. ‘shiny’) in your Description.

1. Because the function in my package runs as an interactive graph, I need to enclose it in the following form:
1. “Please ensure that you do not install packages in your functions without the user’s permission.” This is very important, it is a guarantee of open source software security. Other R packages used in your R functions or vignettes shou be import or suggest in DESCRIPTION file, such as mine:
1. The format of license file. You need to declare the license in the DESCRIPTION file, such as mine: License: MIT + file LICENSE. Correspondingly, There is a license file in your package with contents like following:

That’s all. I’ve finally become one in ten thousand of CRAN, and I’m honored to have these cute tags:

This first one is generated by using Travis deployment, and the second one is the lastest version of this package on CRAN. The last three will show the downloads of this package through CRAN.

The page link of the ‘hwordcloud’ package on CRAN is: hwordcloud @CRAN

The Package document link of this package is: hwordcloud.pdf

I also wrote a vignette to introduce the basic usages of this packages: Rendering Word Clouds

Now, you can just use install.packages("hwordcloud") to install this package!

## Tutorials for ‘hwordcloud’

### Installation

A very simple example:

I built nine themes in the package: darkgreen/darkblue/avocado/darkunica/gray/gridlight/grid/sandsignika/sunset, for example, theme grid:

You can explore the rest by yourself.

As for other parameters, here is a complete example:

To present the usage of ‘hwordcloud’ intuitively, I wrote a simple shiny applications, you can run it by executing following codes:

In fact, I also wrote a Chinese vignette, see: 使用R和HighCharts渲染词云图.

You can get Chinese shiny application by running following codes:

Welcome to install and provide suggestions for further improvement.

# R