
Explore practical foundations of R programming and learn best practices for building applications from a developer's perspective, suitable for new and intermediate programmers transitioning from other languages.
Engage in this hands-on beginner-level course teaching data structures, subsetting, and writing functions. Explore the hybrid object-oriented and functional R language, memory behavior, and three-part course materials, with downloadable resources.
Explore the four main data structures—vectors, matrices, arrays, and lists—plus data frames, covering one-, two-, and n-dimensional forms, homogeneous versus heterogeneous types, and their type, length, and attribute properties.
Explore atomic vectors in R, learning the four types—logical, integer, numeric (double), and character—created with c(), and understand assignment, evaluation, and type coercion.
Explore how R tests object types with type of and is functions, and explain coercion with as.numeric, as.integer, and as.double to make vectors homogeneous, including logical, integer, double, and character.
Explore lists as flexible, multi-type data structures in R that can hold vectors, matrices, arrays, data frames, and even other lists, enabling functions to return complex results as a list.
Explore how R uses lists, vectors, and data frames, including c coercion, nested lists, and unlist. See how lm regression yields a 12-component list object.
Use the longhand attributes function and the structure function to attach and inspect object attributes in R, recognizing that names, dimensions, and class remain persistent.
Name elements to create named vectors and access them by name or by index. Learn to force names, modify vectors with setNames, and use names for useful subsetting.
Explore how factors store categorical data in R with predefined levels and internal integers. See how printing shows levels without quotes and how to coerce between character and factor.
Learn how matrices, as two-dimensional data structures of the same type, are created, indexed by row and column, and extended to arrays and higher dimensions with matrix and dim attribute.
Learn how matrices and arrays use length, rows, and columns, and how naming dimensions enables access by name or index for subsetting.
Explore how matrices and arrays in R extend one-dimensional structures, using dimensions, structure, and the dime function to distinguish atomic vectors, lists, and hybrid matrix forms.
Explore matrices and arrays through three quick exercises: learn what dim returns for a vector and how array and matrix tests differ, including three-dimensional arrays via the array function.
Explore practical solutions to matrices and arrays exercises, compare matrices to arrays, and learn how is.matrix, is.array, and as.matrix test and coerce objects, including multi-dimensional arrays.
Explain how matrices and arrays differ from atomic vectors and sequences, using the 1 to 5 sequence and one by one matrices to illustrate dimensions and attributes.
Create and manipulate data frames to store heterogeneous column types, with named rows and columns, and learn how to avoid automatic factor conversion by turning off string as factors.
Test if an object is a data frame using class or is.data.frame. Coerce with as.data.frame; avoid cbind or rbind creating matrices or unwanted factors by using direct data frame construction.
Explore how data frames are lists, how to add columns (including a list as a column), and how mismatched row counts produce errors; use I() for literal matrices.
Create a data frame and query its attributes to explore structure. Test as.matrix on frames with mixed types and on frames with zero rows or columns.
Understand data frames as tightly coupled collections of variables, with rows representing observations and columns representing variables of mixed data types. Create frames, inspect attributes, and compare them to matrices.
Create a two-column data frame with A numeric and B a factor, showing column heterogeneity and coercion to factors, and how as.matrix coerces to character unless you override with as.character.
Create empty data frames with zero rows or zero columns using the data frame function, and explore how subscripting and transposition define such structures.
Explore core r data structures—vector, matrix, array, data frame, and list—learn casting between types and perform basic operations through hands-on exercises using sample, sequence, and matrix creation.
Explore solving data structures exercises in R by using sample for random vectors, building a 5x5 array from a sequence, and generating a 20-letter uppercase vector starting at C.
Create a three component list in R with components named A, B, and C from a vector, an array, uppercase letters; use length, str, and unlist to inspect and flatten.
Explore practical data-structure solutions in R programming by manipulating lists and vectors, sampling from a 20-element uppercase vector, accessing elements, unlisting, and why arrays cannot hold heterogeneous list elements.
Explore removing a list component with null, unlisting to a numeric vector, and applying set operations (union, intersect, setdiff, setequal) on vectors A and B.
Construct a five by five matrix with random uniform values between 1 and 100, rounded to two decimals, using R, and examine its conversion to vector, list, and data frame.
Transpose an array with aperm to swap rows and columns, resizing as needed, then form the union of a matrix with all numeric elements from list L and sort ascending.
Master subsetting in R using square brackets on atomic vectors; explore how lists, matrices, and data frames respond to operators and assignment, guided by the structure function.
Master subsetting R objects, from index-based selection and sorting to ordering, logical vectors, recycling, and handling missing values.
Explore advanced subsetting in R, including empty criteria, zero-length selections, and name-based or partial-name matching for atomic vectors, and apply these ideas to matrices and data frames.
Subset matrices and arrays in R across two or more dimensions using multiple vectors, a single vector, or another matrix, with comma separated row and column indices.
Learn to subset higher dimensional data in r using integer or character matrices, create a select matrix, and subset data frames while preserving row and column names.
Explore how to subset data frames by selecting columns and rows, handle factors vs characters, and contrast data frames with matrices and S3 objects.
Practice subsetting across vectors, data frames, and matrices by fixing common errors, exploring subsetting operators, and building a custom diagonal extraction function to compare with diag.
Explore practical subsetting in R with the empty cars dataset, mastering equality checks, row and column selection, and the use of or conditions and proper parentheses for clear, accurate results.
Examine integer versus numeric types and missing values (NA), then master subsetting with vectors and matrices in R, including upper triangular results.
Explore R data frame subsetting with the [rows, columns] syntax, noting that leaving columns blank selects all columns, and implement a diag-like function to extract the matrix diagonal safely.
Explore transpose and diagonal operations on matrices, show built-in and custom diag equivalence, and demonstrate vectorization to replace for loops for efficient handling of irregular matrices.
Explore subsetting techniques in r, including diagonal selection, handling asymmetrical matrices, and using logical indices to replace na values with zeros in large data frames for reliable computations.
Explore subsetting lists in R using the single bracket, double bracket, and dollar sign, noting that [] returns a list while [[]] and $ reveal the contents.
Learn recursive list structures and subsetting in R, using double brackets to reveal inner contents, single brackets to extract data frame subsets, and dollar signs to access columns.
Explore preserving versus simplifying subsetting in R, learning when to keep data frame structures, vectors, or lists, and how drop and indexing affect output types and program correctness.
Explore the $ operator in R programming as a shorthand for retrieving data frame columns, compare it to [[, note partial matching with $ and limitations with object names.
Learn how subsetting in R handles missing and out-of-bounds indices, comparing single bracket to double bracket behavior, including NA_real_ and vectorized results.
Perform a linear regression of mpg on weight using the empty cars dataset, store the model in maade, and extract residual degrees of freedom and R-squared from the model summary.
Learn to extract and interpret linear regression results in R by inspecting an lm object, using summary to view coefficients, residuals, and R-squared, and subsetting for residual degrees of freedom.
Explore subsetting and assignment in r by manipulating a vector x, replacing elements with subscripts, using negative indices, and applying logical indices with n.a. treated as false, while understanding recycling.
Explore conditional subsetting and assignment in R by modifying a data frame’s elements, replacing values with zero under conditions, and preserving the data frame structure using empty subscripts and lapply.
Explore character subsetting and lookup tables in R by using named vectors to map lowercase letters to known and unknown classifications through name-based matching.
Learn integer subsetting in R by matching a grades vector to an info data frame using match or row names to map grades to descriptions like excellence, good, or poor.
Explore random sampling with the sample function, including bootstrapping concepts, selecting rows from a data frame with or without replacement, and using a seed for replicability.
Explore how the order function returns indices for sorting, and how to rearrange a data frame or array by a column using those indices, with tie-breaking and missing values handling.
Expand aggregated counts in R using integer subsetting and the rep function to uncollapse a data frame. Learn how repeated rows modify row names without changing the original data.
Learn practical methods to remove columns from data frames in R, using null assignment and column subsetting, and explore set operations like setdiff and setequal to identify differences and similarities.
Explore selecting rows based on a condition, mastering logical subsetting with equality tests, and using subset to simplify filtering, including De Morgan's laws.
Explore how boolean algebra and sets relate in practical R programming, using sampling, subsetting, and the which function to extract true-valued elements and their indices.
Explore boolean algebra and set operations in R, applying intersection, union, difference, and not with which to filter vectors 1 to 10 and reveal divisible patterns.
Practice subsetting in r with short exercises on permuting data frame columns and rows, sampling random rows (default without replacement), and sorting columns alphabetically.
Explore practical techniques for subsetting and permuting data frames in R, including random column permutations via sample, contiguous row sampling, and sorting with order to rearrange rows and columns.
Build proficiency with the subset function to subset data frames by row and column conditions. Practice on empty cars and air quality datasets to filter by mpg and ozone.
Explore end-of-section exercises using the subset function on the empty cars data frame, practicing row and column subsetting with mpg, cylinders, gears, and select arguments.
Practice end-of-section exercises in R programming to subset air quality and co2 data frames, select columns, and apply and/or logic with head and na handling.
Explore how functions in R are objects with a body, formals, and an environment, and how calls create new environments and support attributes such as class.
Explore primitive functions in R programming, showing how they wrap compiled C code for performance and operate at a low level within the base package, with special argument matching rules.
Explore base and primitive functions in R by listing them, identify the function with the most arguments, and note three components of a function, and printing omits its creation environment.
Practice hands-on R programming by solving function exercises and exploring base package functions. Learn to identify primitive vs user-defined functions and inspect formals to count arguments.
Discover lexical scoping in practical R programming, examining how environments determine where a function obtains variables, with emphasis on name masking, dynamic lookup, and global scope.
Examine name masking and lexical scoping in R, showing how functions create environments, resolve x and y across scopes, and return the last expression.
Demonstrate how, in the global environment, x=1 and nested functions create new environments, with R searching upward for x, y, and z until found.
Examine scoping and closures by creating functions like J that return another function, and see how the environment preserves variables such as y, so K retains its behavior.
Examine lexical scoping in R by comparing functions and variables as objects, and see how environments preserve values and resolve names when functions and variables share names.
Explore lexical scoping and fresh environments in J; observe exists behavior and how super assignment can push values up a level, with potential side effects.
Learn dynamic lookup and lexical scoping in R, see how external dependencies and environment values affect a function's results, and apply cohesive, loosely coupled design to avoid pollution.
Explore dynamic lookup in R by redefining operators and functions, show why manipulating the environment is risky, and learn to clean the environment while understanding interpreted language and replication.
Explore practical R programming: functions exercises II, predict what code returns, and explain how nested function definitions create environments and value lookup, including shadowing and worst practices.
Explore how the c function creates vectors, how masking and highest precedence environments affect evaluation, and how a final local c holds 10.
Explore how in the R language, every operation is a function call, from named functions to infix operators and control flow, with backticks enabling special names and overriding native functions.
Explore how to translate expressions into domain specific languages, create a user defined function like add, and compare vectorized apply, lapply, and sapply across lists and vectors, with subsetting.
Explore how formal arguments differ from actual arguments in R, and learn to map them using positional, named, and partial matching.
Call functions with a list of arguments in R using do.call, passing the function name and an argument list, and compare to direct calls while exploring apply-family helpers.
Explore how default values for formal arguments simplify R functions, with A=1 and B=2 returning when called with no arguments, plus lazy evaluation and missing checks.
Explore lazy evaluation in R, where formal arguments are evaluated only if used, and learn how force triggers evaluation, with lapply and apply illustrating lists vs vectors.
Explore how R's lazy evaluation uses promises, new function environments, and short-circuit logic. Learn how ls, environments, and functions illustrate that only needed expressions evaluate.
Explore how the triple dot ellipsis enables flexible function design in R by accepting extra arguments, enabling calls to other functions like plot, and guiding best practices.
Guide through a mid middle section of r programming function exercises, clarifying odd function calls, what a function returns, and the principles illustrated by returns three and by warnings.
Delve into R programming functions with exercises iii, exploring sample and runif usage, argument matching, and lazy evaluation, while clarifying named versus positional arguments and common pitfalls.
Explore infix operator functions in R, where names sit between arguments and are delimited by percent signs; learn to create, escape, and use custom and built-in infix operators with associativity.
Explore replacement functions in R, using the get symbol to modify x with a value and create a modified copy, highlighting performance implications.
Explore creating user defined infix functions and infix operator, build infix versions of intersect, union, and setdiff, and design a replacement function that mutates a random vector element via sample.
Create and apply infix functions in R to perform set operations such as intersection, union, and set difference, and implement a function that replaces a random vector element using sample.
Explore return values in R: the last expression is returned, use return for early exits, compare pure versus impure functions, and return multiple values with lists through copy-on-modify semantics.
Explore side effects in R programming, contrast pure vs impure functions, and learn about invisible values, printing behavior, and forceful display with parentheses.
Practice end-of-section exercises in practical foundations of R programming to write functions for conditionally adding vectors to a data frame, swapping values by indices, and parsing strings into matrices.
Write a function that conditionally binds a vector as a data frame column when lengths match, otherwise returns the original frame, and explore the sequence function and along with argument.
Explore swapping values in a data frame by index with a temp variable, and build a new column by pasting two integers for each row.
Create a function that sorts a numeric vector in ascending order and doubles each element. Strip letters from an alphanumeric vector, coerce to numbers, and apply the same function.
Practice text processing with string split to parse and segment strings, then build matrices with cbind and apply a function across strings, including digits not in vector check.
Practical Foundations of R Programming is the first course of a learning path that teaches critical foundation skills necessary to create quality code using the free and open-access R programming language. This course, and the courses that follow, are useful for both beginner and intermediate R programmers who want to understand the unique features of R and why "R works the way it does." I have been using, teaching, and writing applications in R for 6 years and have come to appreciate that R is a beautiful and elegant language that is especially well-suited for writing applications for data analytics, and for mathematical and statistical applications. Furthermore, R is superior in terms of inherent graphical data presentation capabilities that go hand-in-hand with exploring and understanding data relationships.
Most introductory R courses, those that do not directly address sharpening one's R programming skills, first teach the important R data structures, then the basics of R functions, and generally the use of base R graphics capabilities. However, these introductory R courses are not targeted at the R programmer population, but rather at the general R user population. This course, Practical Foundations of R Programming, which contains all-unique material compared to my other Udemy R courses, addresses R data structures, R subsetting, and R functions, but from the focused perspective of someone who intends to write efficient higher-level applications using R. It is specifically intended to teach the most important foundation concepts and features of the R programming language which are necessary to understand to write efficient and effective applications in R.
This course, which is exclusively "hands-on," demonstrates the construction and use of R code within the RStudio IDE, and focuses on the unique features of R that can make writing applications in R both a challenge and a delight. The course does not present a single power point slide and relies heavily on user exercises. In each of the three major sections of the course, (1) data structures, (2) subsetting, and (3) functions, there are multiple sets of within-section exercises, as well as a final end-of-section exercise set. Participants are encouraged to complete each set of exercises "on their own" before they view the videos that present the exercise solutions. All course videos, and all exercises, as well as their solutions, are presented within R scripts that are made accessible with the course materials. Anything and everything that you see me demonstrate and/or discuss in the 100+ course videos are available for you to download at the beginning of the course.
The second course in this learning path, which should be available to you by the time you complete this first course, will delve more deeply into functional programming in R per se. The second course will have a similar format to this first course: all "hands-on" with extensive use of practical and relevant in-section, and end-of-section, exercises.