So far in this series, we used vectors from built-in datasets (rivers, women and nhtemp), or created them by stringing together several numbers with the c function (e.g. c(1, 2, 3, 4)). R offers an extremely useful shortcut to create vectors of the latter kind, which is the colon : operator. Instead of having to […]
Vectors and Functions
In the previous set we started with arithmetic operations on vectors. We’ll take this a step further now, by practising functions to summarize, sort and round the elements of a vector. Sofar, the functions we have practised (log, sqrt, exp, sin, cos, and acos) always return a vector with the same length as the input […]
Working With Vectors
In the previous exercise set we practised vectors as a data structure. As I noted at the beginning of that set, perhaps you were already familiar with data in a vector-like structure in other applications such as Microsoft Excel or SPSS. If so, perhaps you also used those data to carry out calculations. In this […]
Creating vectors
A vector is the most elementary way to store and structure data in R. For now, think of it as a list of numbers, which can be as short as a single number, or as long as about 2 billion(!) numbers. Perhaps you were used to working with lists of numbers already in a spreadsheet […]
The Mysterious Ellipsis: Tutorial
If you have any basic experience with R, you probably noticed that R uses three dots ellipsis (…) to allow functions to take arguments that weren’t pre-defined or hard-coded when the function was built. Even though R beginners are usually aware of this behavior, especially due to some common functions that implement it (for example, […]
Modularize your Shiny Apps: Exercises
Shiny modules are short (well, usually short) server and UI functions, that can be connected to each other by a common namespace, and be embedded within a regular Shiny app. You can’t run a Shiny module without a parent Shiny app. The modules can contain both inputs and outputs, and are usually centered around a […]
Master of Computer Science in Data Science Application Deadline 15 Oct
Obviously, there’s nothing wrong with teaching yourself R and data science, enrolling in a few popular online courses and practicing here on R-exercises… But how about a real degree? The University of Illinois is offering an online Master degree in Computer Science / Data Science (MCS-DS). The program starts in January, and the application deadline […]
Prettify your Shiny Tables with DT: Exercises
Have you ever wanted to make your Shiny tables interactive, more functional and look better? The DT package, which stands for “DataTables”, provides an R interface to the JavaScript library “DataTables”. It allows creating high standard tables by implementing the functionalities and design features that are available through the “DataTables” library. Even though the DT […]
Pull the Right Strings with stringr: Exercises
By providing a set of wrappers to existing functions, the stringr package allows for simple, consistent and efficient manipulations of strings in R. Even though there are some more basic packages that offer strings-related functions, you might find yourself in need for a more complete and straightforward solution for handling strings in R. With a […]
Automating and Scheduling R Scripts in Windows: Tutorial
This tutorial will teach you how to run and schedule R scripts from the command line. Even though parts of this tutorial applies for other operating systems as well, the focus will be on Windows, since it is a bit less straightforward than in other systems. By the end of this tutorial, you will have […]