This is a short guide summarizing my limited knowledge of how to make and install packages in R using a Mac. It borrows very heavily from P. Rossi's 'Making R Packages Under Windows: A Tutorial' (1/06) which in turns borrows very heavily from the standard work 'Writing R extensions' (available as a pdf from CRAN but also available as part of the R installation. Start the browser version of help.start(). This guide, and any of my contributions, owe a great deal to the wonderful contributions of the R team.
You are invited to join MAC Academy The MAC Program helps 15-24 year old refugees with: Jobs (application, resume, cover letter etc.) Driver's license High School Equivalency Diploma English (day and evening classes, tutoring) Career and Technical Education Training (CNA, Electrical, Culinary and many more) Work Experience FREE Tours of Rochester (colleges, theatres, museums, businesses, etc. A Hackintosh is a non-Apple computer that runs macOS. AMD USERS READ THIS: While it may be more work, the AMD hackintosh scene has gotten quite a bit easier. Do note we're primarily an intel subreddit but feel free to ask questions relating to AMD based systems. Step1 is common for all platforms(Mac, Windows, and Linux). Execute the below code on your R programming console. Install.packages('devtools') Step2: This step is also nearly the same for all OS. However, you have to use the corresponding packages URL. Execute the below code on the R Programming console. Windows CatBoost Install Command. R Drive Image Mac Os Free You can create a disk image that includes the data and free space on a physical disk or connected device, such as a USB device. For example, if a USB device or volume is 80GB with 10GB of data, the disk image will be 80GB in size and include data and free space. Also, consult the R for Mac OS FAQ page which is the definitive resource for building packages, but does assume more ability than I seem to have to follow it completely. Notes: In the various tutorials, one will see the R CMD X line. This means that one should execute this line while using the console (using X-11), not from the R Gui.
This guide was developed as way for me to take notes as I tried to convert a number of routines into a more easilly managed 'package'. It is geared to the Mac user who is clueless with respect to Windows and can stumble around (with some limited success) in the Unix part of the Mac.
An equally frustrated pair of users created this guide for Linux, Unix and Windows users. (Unfortunately, their page has a link for how to build packages for Macs and it refers back to this page. So, I can just recommend reading that page for other hints.)
Also, consult the R for Mac OS FAQ page which is the definitive resource for building packages, but does assume more ability than I seem to have to follow it completely.
Notes:
- In the various tutorials, one will see the
R CMD X
line. This means that one should execute this line while using the console (using X-11), not from the R Gui. Although perhaps obvious to everyone else, this was not obvious to me. - Files will be created from various routines (e.g., prompt), that will need to be moved to where you are building your packages.
- The home location for R packages from the Mac finder on my machine is 'desktop/Macintosh HD/Library/Frameworks/R.framework/Resources/library/'. Within library you will see all the packages that you have downloaded, and installed. Examining some of those, e.g., the sem package, helps one understand what goes where.
- the 'tools' package should be installed.
Making the package -- the first time
- package.skeleton(name = 'anRpackage', list, environment = .GlobalEnv, path = '.', force = FALSE) will createthe appropriate files for a package.
So, for instance in making up the psych package, the first step is to make the skeleton. This list is strung out to make it more readable. Note that I include a dummy function (psych) with the same name as the package. This allows one to get help by merely asking ?psych. (This seems to have changed in version 2.3.1 and now the skeleton automatically makes up a file with the name of the package - This then creates a new folder (at the root directory level) that has draft DESCRIPTION, INDEX, AND CONTENT files, and three folders: R, man, and scr, in addition to a 'read and delete me file that says '
- The R folder/directory contains each function listed in the call to the skeleton function created as an individual file with the suffix R. e.g., alpha.scale.R, omega.R, etc. Corrections to your code can be done directly to these files.
- The man folder/directory has has a number of short files that include basic descriptions of each function. These need to be edited to provide basic information for the help files. Particular, the ~kwd1 and ~kwd2 should match the Contents file and use keywords from the KEYWORDS.db.
Note, that the files in the man folder are written in a .Rd format. This format is used by R to create HTML and LaTex files. Although it is tempting to edit the html files that will eventually appear in the library, it turns out that one needs to learn to edit the Rd formated files. See section 2 of the package manual. The process of building the package takes these Rd files and converts them to HTML as well as Latex and (perhaps) pdf. As Rossi points out, it is vital to write clear documentation for your functions. This is, of course, the least fun part of program development, but essential.
The syntax of these .Rd files is moderately straight forward. The % mark signifies a comment. All commands start with a and are defined within { }.
- We now have a folder that can be built. But first, we need to correct the description file. (Without fixing the description that comes out of package.skeleton, build fails.) In addition, as far as I can tell, periods are not allowed in the Description.
An example description file
- At this point you can go to the X11 window and use the R CMD build psych command.
- Building will produce a tar.gz file that can be loaded using the package installer. The package manager, in turn, will take that file and create the appropriate HTML and pdf help files.
The package installer can load local packages (as source files) from your root directory. The installer then makes the html and pdf help files based upon your .Rd files.
If corrections to the package are to be made, they should be done in the original files in the original folder and then the build sequence can be followed again.
- R CMD check psych will check all the syntax of your files, including the help files. Its diagnostics will appear on the screen as well as in the psych.R.check folder. Fixing all the complaints will take a while, but is necessary to make a package that can be sent to CRAN.
Adding corrections and additions to the packageKill dr. cote mac os. If you want to add any new functions to the package, you can save the function as foo.R in the R folder of the package and then add the appropriate help file (.Rd) in the man folder/directory. To create the new help file, use the prompt(foo) command. This will write foo.Rd into the man directory (folder).
After adding a new function (foo.R) to the foo.package directory and running prompt(foo.R) to create the foo.Rd file to be put in the foo.man directory, run R CMD check foo.package until no errors occur. (Be patient.)
Examine the Contents file and give keywords that match those found in the KEYWORDS.db file for R. Also add 1 line descriptions to each function. The index is created by the package manager, and uses the one line desciption files.
Sharing your package -- repositories and CRANWe now have a workable package. This can be tested and uploaded to Cran, or can be installed in a local 'repository' for further testing and development. Note, that if the package is just written in R, it is loaded as source rather than as binary.
The use of repositories has been discussed in Rnews by Brian Ripley. Repositories are meant for development of department or university wide packages that might not be of general interest. I have been doing this for the psych package, trying to maintain both a PC and a Mac version. The Mac version has the requirement (according to the Mac FAQ): 'A Mac OS X specific requirements, is that a prebuilt package is assumed to be named (and accordingly archived and compressed) as package_name.tgz. On Windows, for example, packages come in a zipped format.'
To do this, we need to create a number of folders (directories if using a PC) and files. The basic default location for my repository is
- http://personality-project.org/r/
This has a folder (directory) of src which contains - contrib which contains at least 3 files:
- PACKAGES
- This file is a listing of the packages in the repository.
- for me, with one file it is merely
Package: psych
Version: 1.0-7
Depends: NA
- PACKAGES.html
A basic html file with a table describing the various packages. - psych_1.0-7.tar.gz the actual package
- as well as the folders:
- Descriptions which contains
- psych.html
- Descriptions which contains
- PACKAGES
Appropriate read permissions need to be added to these files and folders to allow others to access them.
Once this is done once, it is then possible to do direct edits to this set of files to make improvements to the package. However, this is a bad idea. It is much better to make the corrections to the package master folder (the pre built one, not the installed one), for that corrects the help files as well.
- Files to fix
- actual program corrections may be done to the file 'psych' in the subdirectory (folder) R. When the package is rebuilt, these corrections will be added to the package.
- Corrections to the help documentation can be done to the files in the folder Help. However, these are not actually part of the package, unless the corrections are done to the .Rd files.
- HTML help files are found in the HTML folder. These are the files that are used when asking for help or from the index. I had thought these are the most important to revise, and although this can be done, it is better to spend the time fixing the .Rd files and the remaking the package.
Once the habit of correcting .Rd files and function.R files becomes routinized, then the rebuilding operation is fairly straight forward.
R CMD check psych is a very useful (although tedious) operation. This will work through mistake after mistake in the .Rd files. Correct these!
Using X-11 to finish
- After doing corrections to the various files, one can make an updated tgz package by using X-11
- tar --create -f psych.1.0-7.tar psych (takes the folder psych and compresses it)
- gzip psych.1.0-7.tar (takes the file and gzips it)
- zip -r psych psych (makes a zip file for pc users)
- then, it is necessary to set the correct permissions for these files so that they can be read.
Then, finally, we move the psych.1.0-7.tgz file to the PACKAGEs folder and it is ready to be installed by other Mac users.
I think it is preferred to actually do this to the result of the build operation rather than the folder inside the library.
To allow PC users to use the package, they need to be able to download the zip file. Holey moley (wcb) mac os. Thus, they need to be able to find it! I have created a folder r/bin/pcos that has the psych package. Presumably some introductory remarks similar to those found in the Mac package structure would be helpful.
How to set up a repository using BioConductor is discussed by the bioconductor folk, (but I am unable to make this work).http://www.maths.lth.se/help/R/.R/library/reposTools/doc/reposServer.pdf
With my package 'psych' installed on the personality-project.org server, one can install it by using the R-package installer and specifying 'other respository' with the address http://personality-project.org/r . It magically works its way down the file structure to get the appropriate package.
part of a short guide to R
Version of June 13, 2006
William Revelle
Department of Psychology
Northwestern University - http://personality-project.org/r/
Finally, you've decided to give R a try. Great!
Now, let's install it on your desktop/laptop. I will provide a step-by-step guide on installing R and RStudio (more on this later) both on Mac OS X and Windows.
R and RStudio: Complementary, Not Substitutes
Before we begin, I can imagine some of you might be wondering: 'I thought we're going to install R, why should we install another software? What does RStudio have to do with R?'.
Well, R is a programming language, primarily for statistical computing and graphics.
RStudio, on the other hand, is a software which enables you to develop R code easily since it comes with useful features.
One of the simplest explanations about the difference between R and RStudio that I can find around the web is this explanation from moderndive.com:
'R is a car's engine while RStudio is like a car's dashboard'.
I hope you've got the idea by now. However, I'm pretty sure that you'll understand that automotive analogy above once you run the software.
Install in Mac OS X
R
- First, go to https://cran.r-project.org/mirrors.html. The page will show you a quite exhaustive list of mirror sites. Just pick one which is closer to your current location
R Academy Mac Os 11
- When you click one of the mirrors, you'll be directed to another page which shows you three download options to accommodate three operating systems (Linux, Mac OS X, and Windows). Obviously, you should click 'Download R for (Mac) OS X'.
- You'll land to another text-heavy page. In this page, you should be able to read a bit explanation about the current R version (at the time of writing, it's version 3.6.1 or 'Action of the Toes'). You might want to skip that part and go straight under the heading of 'Latest release:'. Chances are you'll have to click and download two files for R to work properly on Mac OS X:
- R binary. This is the *.pkg file that is labeled with R followed by its current version (e.g. for version 3.6.1, its R-3.6.1.pkg).
- XQuartz. Click the link provided or go to XQuartz's homepage to download the latest version of XQuartz. Note that you'll need to re-install XQuartz when upgrading your Mac OS to a new major version.
- After downloading, I suggest you install R first then XQuartz. You're done? Congrats! We're halfway done. Now let's install RStudio.
RStudio
- Go to this page https://www.rstudio.com/products/rstudio/download/. You'll see a table comparing the features of four different versions of RStudio: Desktop with Open Source license, Desktop with Commercial license, Server with Open Source license, and Server with Commercial license.
- Click the download button for RStudio Desktop with Open Source license. You'll see a list of installers for different operating systems. Download the one for Mac OS 10.12+. Note that the current version of RStudio only works on a 64-bit operating system. If you're still stuck in 32-bit OS, you can access the older version of RStudio via the provided link on the same page.
- After downloading, just install the application.
Install in Windows
R
- Same with Mac OS X, go to the https://cran.r-project.org/mirrors.html. The page will show you a list of mirror sites. Just pick one which is closer to your current location.
- When you click one of the mirrors, you'll be directed to another page which shows you three download options to accommodate three operating systems (Linux, Mac OS X, and Windows). You'd want to click 'Download R for Windows'.
- You'll be directed to a page with four subdirectories: base, contrib, old contrib, and Rtools. Click 'base'.
R Academy Mac Os X
- Unlike the Mac OS X version, the link to download R for Windows is quite obvious. Just click 'Download R for Windows' to download the *.exe file. (at the time of writing, the current version is 3.6.1).
- Just install the downloaded *.exe file and next, we're going for RStudio.
RStudio
- Go to this page https://www.rstudio.com/products/rstudio/download/. You'll see a table comparing the features of four different versions of RStudio: Desktop with Open Source license, Desktop with Commercial license, Server with Open Source license, and Server with Commercial license.
- Click the download button for RStudio Desktop with Open Source license. You'll see a list of installers for different operating systems. Download the one for Windows 7+. Note that the current version of RStudio only works on a 64-bit operating system. If you're still stuck in 32-bit OS, you can access the older version of RStudio via the provided link on the same page.
- After downloading, just install the application.
What to do after installing?
You did it! Now, you can start to tinker with R using RStudio. So, you need to remember, run the RStudio application, not R!
Well, that's the end for the guide for now. I'm planning to update this guide from time to time whenever I see fit. So watch this space.
Perfect octave mac os. Note: this article has been updated on Jan 9, 2021 to fix the missing screenshots.
Have you installed R and RStudio successfully using this guide? Do you find the guide useful? Or is it confusing? Or maybe you're stuck somewhere along the way? Do you think I've abused too many red arrows?
R On Mac
Please let me know in the comment section below.