13.3 Check and build a package - Video Tutorials & Practice Problems
Video duration:
2m
Play a video:
<v Voiceover>Now that the</v> package is properly written and documented, it's time to check it and if it passes, build it. But first things, let's clean up the file a little bit. Since we're not using ggplot2 or plyr, there's no point in importing it, it just confuses things, let's get rid of them. To do that, we should also get rid of them in the description file. Now, we can load devtools and redocument our package. In the past, checking a package was kinda difficult. You had to go into the terminal and do some (mumbles) commands like R, C, M, D, check and hope you're not too scared. Now though, it's simple using check. This runs through, does all the checks it needs to do. It tells you if you pass or fail. So, it looks like we did good. So now that we're ready to build, it's as simple as using the build function. There we have it. It went ahead and packaged our code up into a tar.gz. That's right here. Simple_1.0.0.tar.gz. The first part is the name of the package and the second part is the version number. Now this can be passed around to Windows users, MAC users, Linux users, or upload it to CRAN. If you want to make a binary that's prebuilt ready to go for Windows, you can say build and then binary equals TRUE. Running this, instead of building a tar.gz, we'll build a zip file, which you can easily install in Windows. Now, either the tar.gz or zip will be perfectly good, the only advantage to having a zip as to have a tar.gz is if it's a very large package or it has compiled code in it and you don't want your end user to have to deal with that, you could give them a zip and it's ready to go. Otherwise, the tar.gz is fine. So there, there's two simple commands, check and build. It takes out almost all of the fear of building packages and makes it nice and easy. You never even need to leave R. You just need to run the check function and the build function and you're ready to go.