Make a new R Package project in RStudio:
File > New Project > New Directory > R Package
.
Name your package cryptoXYZ
, where XYZ
are
your initials. Choose a directory where your package will reside (as a
subdirectory). Open the package in a new session.
Add the file shiftcipher.R
to your project by putting it in the R
subdirectory.
Install the roxygen2
package. (Windows users may also have
to install RTools and the
magrittr
package to get roxygen2
to work.) Get
rid of the stubs hello.R
in the R
directory
and hello.Rd
in the man
directory. In the
Build
tab, click on More
and
Configure Build Tools...
, and check the box that says
“Generate documentation with Roxygen”. In Roxygen Options
,
check the box that says to automatically reoxygenize when running
Install and Restart. Click OK (twice). Now use the Install dropdown to
Clean and Install
your project and see what happens. When
you view your list of packages, you should see your new package, and you
should be able to browse the documentation and use the
functions.
Add the file affinecipher.R
to the R
subdirectory of your project. This file contains
ROxygen comments and a template for an affineCipher
function, which should consume a string plainText
and
integers alpha
and beta
, and it should return
the ciphertext corresponding to the plaintext under the affine cipher
represented by the function \(x
\stackrel{s}{\longmapsto} \alpha x + \beta\) (that is, the
function given by the formula \(s(x)=\alpha x
+ \beta\)). Model your function on the shiftCipher
function of the previous question. Add an example to the documentation
illustrating the cat example that we did in class.
Clean and Install
and check that your example appears in
the documentation. Click on the Run Examples
link and see
if your function works.
Edit the DESCRIPTION
file appropriately. Leave the
version number as 0.1.0
.
Click on More
in the build menu, and this time build
a source package. A new file called cryptoXYZ_0.1.0.tar.gz
should appear in the parent directory. Upload this file to
Canvas.