Get startedGet started for free

Get help and load data in R

1. R session = environment + packages

Hello, I am Melinda Higgins your guide on your journey to learning R. Throughout this course, you'll learn the similarities and differences between SAS and R. Each chapter will provide a detailed mapping of R functions to SAS procedures. In this first video you will learn about R's global computing environment and adding functionality through packages.

2. Why learn R?

So, why learn R? R is free in terms of cost and licensing. Jobs requiring R are growing rapidly and scholarly articles using R now surpass those using SAS. R can be run with minimal resources and requires less than 100MB to install. Also R is free.

3. A computing session SAS vs R

Let's compare SAS and R. SAS's computing session includes installed components plus

4. A computing session SAS vs R

datasets and associated files loaded in the WORK library.

5. A computing session SAS vs R

R's computing session consists of functionality provided by packages plus

6. A computing session SAS vs R

datasets and other objects stored in R's global environment.

7. A computing session SAS vs R

SAS's functionality comes from numerous components installed with the base software, whereas R begins with only a minimal set of packages. Other packages must be loaded to add functionality as needed.

8. A computing session SAS vs R

Like SAS's WORK library containing datasets and related files created or used during a SAS session, R's global environment stores all datasets and related objects created or used during an R session.

9. Data and other objects

The datasets and other objects that are available in memory during your R session can be seen by running the ls or list command similar to running PROC DATASETS in SAS.

10. Load data files

In this first chapter, you will load a dataset in the RData binary format, like loading a SAS7BDAT datafile using SAS LIBNAME and a DATA step.

11. Global environment - new session

Let's take a look at a typical R session and the global environment. When an R session begins it is usually empty with zero objects loaded in memory - confirmed by running the ls command. Character0 indicates no objects in session memory. Let's load some data and see how this changes.

12. Load data

Throughout this course you will work with the abalone dataset from University of California Irvine's Machine Learning Repository. Abalones are shellfish similar to clams, mussels or oysters. The data were collected by a marine research lab in Australia to predict abalone ages from their measurements. The abalone dataset in RData format is loaded using the load function with the filename provided between parentheses and quotation marks. Running ls again now shows one object in session memory.

13. Getting help

Like clicking the help button in SAS, you can get help in R by running the help command.

14. R help

For example, to get help on the list function, simply type help followed by ls provided between the parentheses. This opens the help page for ls.

15. Settings and functionality

Similar to SETINIT and PRODUCT_STATUS procedures in SAS which provide information about installed components and your computational environment, R's sessioninfo command provides details on the computer operating system and loaded packages. R's library command is used to load R packages. Tens of thousands of packages are available for R from CRAN.

16. R sessionInfo

This sessionInfo output shows the version of R running, the computer operating system and packages loaded. R starts with seven basic R packages, listed under attached base packages.

17. R sessionInfo

Throughout this course you will use the dplyr package for modifying and summarizing datasets. In order to load the dplyr package to your session, use the library function with the package name provided inside the parentheses. Now the sessionInfo output shows that dplyr is loaded under other attached packages.

18. Let's get started on your first R session

Let's get started on your first R session