Find below a friendly, step-by-step online classes, in Portuguese -- you may enable YouTube's auto-translation and choose a language of your preference --, to introduce you to the powerful R statistical programming language. These classes are based on the textbook 'R for Data Science' by Wickham & Grolemund (2017).
R RStudio -- Class 1 -- How to Install / Instalação
This video provides a tutorial on how to install R and RStudio software. The speaker guides viewers through the installation process step-by-step, focusing on a Windows operating system. The video aims to make the installation process clear and easy to follow, even for beginners.
Key Takeaways
The video demonstrates a step-by-step installation of R and RStudio on Windows.
The process is presented as relatively quick and straightforward.
Language options during installation are highlighted (Portuguese Brazilian is shown).
The speaker emphasizes the importance of completing each installation step.
The video shows what the RStudio interface looks like after successful installation.
R RStudio -- Class 2 -- Interface / Interface
This video provides a tutorial on the RStudio interface, focusing on basic commands and functionalities. The instructor demonstrates how to use RStudio for simple arithmetic operations and explains how to interpret the results displayed. The video also touches upon the use of comments (#) in R code for better understanding and collaboration.
Key Takeaways
Basic Arithmetic in RStudio: The video demonstrates how to perform basic arithmetic operations (+, -, *, /) within RStudio's console.
Interpreting Output: The tutorial explains how to interpret the numerical output generated by RStudio commands, including the indexing of results.
Handling Incomplete Commands: The video shows how RStudio handles incomplete commands and how to correct them by adding the missing closing elements.
Using Comments (#): The instructor explains the importance of using the '#' symbol to add comments to R code for improved clarity and collaboration. These comments are ignored by the R interpreter.
Error Messages: The video demonstrates how error messages appear in RStudio and that they simply indicate that a command was not recognized, requiring correction.
R RStudio -- Class 3 -- Objects / Objetos
This video is a tutorial on objects in RStudio. The speaker explains how to create, save, and manipulate objects, emphasizing the importance of understanding object names (case sensitivity) and potential issues when performing operations on objects of differing lengths.
Key Takeaways
Object Creation and Saving: The video demonstrates how to create and save numerical sequences (vectors) as objects in RStudio. This allows for storage and reuse of data.
Object Names: RStudio is case-sensitive; a and A are distinct objects. Careful naming is crucial to avoid overwriting.
Object Operations: Mathematical operations (addition, subtraction, multiplication, division) can be performed on objects. However, errors occur if operations involve objects of unequal lengths.
Error Handling: The video shows how attempting operations with objects of incompatible sizes results in error messages.
Matrix Operations: The video briefly mentions the use of matrices and shows the command for matrix representation.
R RStudio -- Class 4 -- Functions / Funções
This fourth tutorial introduces basic functions and arguments in the R programming language. The instructor demonstrates how to use functions like round, factorial, and mean for calculations, and explains how to utilize the sample function for generating random values. The core focus is on understanding function arguments and best practices for using them.
Key Takeaways
Basic R Functions: The video showcases several built-in R functions, including round, factorial, mean, and sample.
Function Arguments: The concept of function arguments is explained, emphasizing that arguments provide inputs to functions. The importance of clearly naming arguments is stressed, particularly when dealing with functions with multiple arguments.
sample() Function: The sample() function's usage is demonstrated, showing how to obtain random samples from a data set using arguments like x (data), size (number of samples), replace (sampling with replacement), and prob (probabilities).
Argument Naming Best Practices: The instructor advocates for explicitly naming function arguments, even when default values might seem unnecessary. This improves code readability and reduces errors, especially when functions have multiple arguments.
Using args(): The args() function can be used to check the arguments a given function accepts.
R RStudio -- Class 5 -- Sample Replacement / Substituição de Amostra
This video is a tutorial on using RStudio. The main focus is on explaining the sample function and how the replace argument works within it, particularly demonstrating how to obtain random, yet repeatable, results when sampling from a dataset. The instructor uses a visual, step-by-step approach to clarify the function's behavior and address potential issues.
Key Takeaways
The sample function in RStudio is used for sampling data.
The replace argument in the sample function controls whether sampling is done with or without replacement. Sampling with replacement allows the same value to be selected multiple times.
Using replace = TRUE in the sample function ensures that when a value is selected, it's returned to the dataset, enabling repeated selections of the same value. This is crucial for simulations or scenarios requiring replacement.
Without replace = TRUE (or replace = FALSE), a value once selected is removed from the dataset, preventing its re-selection.
The video demonstrates how to troubleshoot common issues when using the sample function.
R RStudio -- Class 6 -- Function Constructor / Construindo Funções
This video tutorial demonstrates how to create custom functions in RStudio. The instructor guides viewers through building a function to simulate rolling two dice and obtaining unique results, contrasting it with previous examples where results were identical. The focus is on constructing the function's structure and understanding its components.
Key Takeaways
The video explains the fundamental structure of a function in R, including naming conventions, parentheses for arguments, and curly braces for the function's body.
It emphasizes the importance of creating functions for code reusability and better organization.
The tutorial uses the example of a dice-rolling function to illustrate how to handle arguments and generate variable outputs.
The instructor shows how to use the created function within RStudio and interpret its results.
The video highlights that functions in R are treated as objects.
R RStudio -- Class 7 -- Arguments / Argumentos
This video tutorial provides a lesson on using arguments within functions in RStudio. The instructor demonstrates how to define and utilize arguments to improve the functionality and flexibility of custom functions.
Key Takeaways
Function Arguments: The video explains the concept of arguments within R functions, illustrating how they allow for dynamic input and control over function behavior.
Argument Placement: The importance of correctly placing arguments within function calls is highlighted, demonstrating the impact of order and syntax on the results.
Error Handling: The video demonstrates how to identify and address common errors arising from incorrect argument usage, such as missing or misplaced arguments.
Code Structure: Best practices for organizing and formatting code with function arguments are presented, emphasizing the importance of readability and maintainability.
Example Functions: The instructor builds and demonstrates several example functions that employ arguments, providing practical applications and illustrating different use cases.
R RStudio -- Class 8 -- Scripts / Roteiro
This video tutorial provides a formal introduction to scripts in RStudio. It explains how to write, save, and run R scripts, emphasizing their importance for organizing code, sharing work with colleagues, and improving workflow. The instructor demonstrates the process with examples and explains key concepts.
Key Takeaways
Scripts for Organization and Collaboration: Using R scripts provides a structured way to write and manage R code, facilitating collaboration and code sharing.
Formal Code Presentation: Scripts offer a more formal and organized method of presenting code compared to direct execution in the R console.
Script Creation and Saving: The video details the process of creating a new script, writing code within it, and saving it as a .R file.
Code Execution and Output: The tutorial demonstrates how to run the code within a script and interpret the resulting output.
Debugging and Iteration: The video implicitly shows how using scripts aids in debugging and iterative code development.
R RStudio -- Class 9 -- Packages / Pacotes
This video is a tutorial on using packages in R and RStudio. The instructor explains how to install and utilize packages to enhance functionality, focusing on data manipulation, visualization, and statistical analysis. The video uses practical examples and code demonstrations.
Key Takeaways
Package Installation and Usage: The video demonstrates how to install and load R packages using the install.packages() and library() functions. It shows how to access the functions within a package once installed.
Data Visualization with Packages: The tutorial uses the ggplot2 package (though not explicitly named) to create scatter plots and histograms for data visualization. It emphasizes the importance of visualizing data for analysis.
Data Manipulation and Statistical Analysis: The video illustrates data manipulation techniques within the R environment, applying functions from packages to analyze data distributions. The concept of fair vs. manipulated data is explored through simulations.
Replication and Simulation: The video demonstrates how to replicate simulations using R functions, repeatedly running code to analyze the distribution of results and check for fairness or manipulation. This is applied in a dice-rolling example.
Understanding Package Functions: The instructor explains how to access the help documentation for a package function using the ? operator, providing a method for learning the specifics of various commands and their arguments.
R RStudio -- Class 9 -- Packages 2
This video is the second part of a three-part series on RStudio packages. It focuses on using packages to perform simulations, visualize data, and manipulate results, particularly within the context of statistical analysis and data visualization. The instructor explains how to install and utilize packages, demonstrating various functions for creating graphs and analyzing data distributions.
Key Takeaways
Package Installation and Usage: The video details how to install and load R packages, explaining their role in providing pre-built functions and tools for data analysis.
Data Visualization with Packages: Several visualization techniques are shown, including scatter plots and histograms, using functions from loaded packages. The importance of visualizing data for understanding distributions and potential biases is emphasized.
Data Manipulation and Simulation: The video demonstrates how to manipulate data using R functions, focusing on creating simulations involving dice rolls and analyzing the results for fairness. This includes replicating simulations multiple times to assess the consistency of results.
Statistical Analysis Concepts: The instructor highlights concepts such as data distribution, probability, and the identification of potential biases or manipulations in data.
RStudio Environment Navigation: The video shows how to navigate the RStudio environment, utilize functions, interpret error messages, and explore package functionalities.
R RStudio -- Class 10 -- Atomic Vectors / Vetores Atômicos
This video tutorial focuses on atomic vectors in RStudio. The instructor uses the context of creating a card game (poker) to illustrate concepts related to data storage, retrieval, modification, and type checking within the R programming language.
Key Takeaways
Atomic Vectors: The video introduces atomic vectors as the simplest data structure in R, explaining their unidimensional nature and various types.
Vector Types: Different types of atomic vectors are covered: integer, double (numeric), character (text), and logical (boolean). The importance of using correct data types for accurate calculations and operations is highlighted.
Data Type Identification: The video demonstrates how to check the type of a vector using the typeof() function in R.
String Handling: The significance of enclosing text within quotes to define character vectors and avoid errors is emphasized.
Practical Application: The lesson culminates in creating a simple poker hand as a practical exercise to reinforce the learned concepts.
R RStudio -- Class 11 -- Attributes / Atributos
This video tutorial provides a lesson on attributes in R and RStudio. The instructor explains how to assign attributes to objects, emphasizing that attributes are metadata—information about the data—rather than influencing calculations. The lesson covers different data structures like vectors, matrices, and lists, demonstrating how to create and manipulate them with specific functions and illustrating their use through practical examples.
Key Takeaways
Attributes as Metadata: Attributes in R are supplementary information attached to objects, acting as metadata and not affecting calculations.
Data Structures: The video demonstrates the creation and manipulation of various data structures, including vectors, matrices (with varying dimensions), and lists. It shows how to define dimensions (rows and columns) for matrices and how different functions handle data types.
Data Type Handling: The instructor highlights how R handles different data types (numeric, character, logical) within data structures, especially when mixing types within a vector. R often coerces data types, which can lead to unintended consequences if not managed correctly. Functions like factor are introduced to control this coercion for categorical data.
Functions for Data Manipulation: The video utilizes several R functions, such as matrix, list, and functions for data input/output, to create, modify, and save data structures.
Data Import/Export: The video demonstrates how to import and export data, specifically focusing on the .csv format and highlighting the importance of understanding the separator used in the data file.
R RStudio -- Class 12 -- Selecionando Valores
This video tutorial focuses on selecting values from vectors and databases using the R programming language. The instructor demonstrates various methods for selecting data subsets, including using positive and negative integers, logical indexing, and selecting by column names.
Key Takeaways
Using Positive Integers: Selecting elements using positive integers specifies the desired position(s).
Using Negative Integers: Selecting elements by using negative integers excludes the specified positions. This is efficient for removing small numbers of elements.
Logical Indexing: Employing logical vectors (TRUE/FALSE) allows for selection based on conditions.
Selecting by Column Name: Utilizing column names directly enables more readable and intuitive data selection.
drop = FALSE: Using drop = FALSE prevents R from simplifying the output dimensions, maintaining the original structure of the data.
R RStudio -- Class 13 -- Deal Card
This video is a tutorial on R and RStudio, focusing on manipulating a deck of cards as a data structure. The instructor demonstrates how to shuffle a deck randomly, draw cards, and use various R functions and symbols (like brackets [], dollar signs $, and other notations) to extract and manipulate data within the deck.
Key Takeaways
Shuffling a deck: The video demonstrates methods for randomly shuffling a deck of cards represented as a data structure in R.
Card extraction: The video teaches how to extract specific cards from the shuffled deck using R's indexing capabilities and various notations (brackets [], dollar sign $).
Data manipulation: The tutorial covers using R functions and symbols to manipulate and access data within the deck structure, like extracting specific card values or subsets of cards.
R syntax for data manipulation: The video provides practical examples of R code snippets and functions for handling data structures, including techniques to extract and reorder elements.
Understanding different notations: The tutorial highlights the differences in functionality between using brackets [], dollar signs $, for data extraction, demonstrating their uses in creating subsets and accessing specific elements.