Recap of Essential R Programming Concepts
Recap of Essential R Programming Concepts
Are you excited to continue your journey in data science with R? In this section, we'll revisit some of the foundational R programming concepts you've already encountered, ensuring you're well-prepared for more advanced topics. Our focus will be on data structures, basic operations, control structures, and custom functions in R.
What You'll Learn
We'll cover the following key concepts in this lesson:
- Data Structures: Refresh your understanding of vectors, matrices, lists, and data frames.
- Basic Operations: Revisit arithmetic operations, calculating mean and sum, and type conversions.
- Control Structures: Recap how to use conditionals (
if-else), loops (for,while), and custom functions in R.
Data Structures
Let's start by refreshing our knowledge of different data structures in R: vectors, matrices, lists, and data frames.
Vectors
Vectors are one-dimensional arrays that can hold numeric, character, or logical data types.
In this example, nums is a numeric vector containing the numbers 1 through 5.
Matrices
Matrices are two-dimensional arrays that hold elements of the same data type.
Here, matrix_example is a 3x3 matrix filled by rows with numbers from 1 to 9.
Lists
Lists in R can hold elements of different types, including other lists.
In this example, list_example contains a vector, a matrix, and a character vector.
Data Frames
Data frames are two-dimensional tables where each column can hold different types of data.
Here, df is a data frame with three columns: ID, Name, and Score.
