Ad space (banner)
๐Ÿ“ŠR Lessons
Lesson 13 / 68

Using the handy built-in functions

This lesson covers R's handy built-in functions, with the aim of knowing what you do not have to write yourself.

Convenient functions for handling text come as standard, such as toupper() and sprintf(). R's standard library is designed with statistics in mind, and simply knowing what is there makes implementation much easier.

The sample code converts to upper case with toupper("hello"), zero-pads with sprintf("%03d", 7), and gets a vector's length with length(c(1, 2, 3)). Knowing the string and vector functions makes you dramatically faster.

A common early stumble is not knowing what is available and writing the same thing out at length yourself. Getting into the habit of checking the documentation for something similar is worth a great deal.

In professional work, how well you know the standard functions directly affects both code quality and development speed.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run R directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)