This is an example R package project that uses code written in Java.
For a concise introduction to rJava, read "Documentation" section on the webpage of the rJava project .
The goal of this project is to show the following things.
testthat
package).@export
annotation.Note that in order to be able to build the project, you need to have all R packages listed in the Imports section of the DESCRIPTION
file installed in the system.
*.Rproj
file: its nameDESCRIPTION
fileusage_example_of_installed_package.R
file: library
statementtests/testthat.R
file: library
statement and as an argument to test_check
calldevtools::check()
two NOTEs are printed related to the following things.GNU make
is a system requirement of the package (as defined in the DESCRIPTION
file). This is required, because in the java/number-adder/Makefile
file we use ifndef
construction which is GNU make extension with regards to POSIX make. Using GNU Make is discouraged because it is not completely portable as noted in "Writing R Extensions" document, section "Writing-portable-packages".NAMESPACE
and directory man
are entered in .gitignore
file. Hadley Wickham disapproves of this in his book (see chapter "Git and GitHub", paragraph starting from "Some developers never commit derived files").If you get a cryptic error message while running the tests similar to the one below:
Error in ._jobjRef_dollar(x[["jobj"]], name) :
no field, method or inner class called 'calls'
Calls: <Anonymous> ... expectation_error -> $ -> $.Throwable -> ._jobjRef_dollar
this might mean that the version of Java that the source files were compiled for is incompatible with the Java version configured in R environment. The version of Java for the source files is set in java/number-adder/pom.xml
while version of Java used in R environment is set using R CMD javareconf
command.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.