R Programming 101: How to Define Variables
Key Takeaways
This video tutorial covers the basics of defining variables in R programming, including assigning values, performing arithmetic operations, and using vectors for storing multiple values. It also demonstrates how to work with R in both the terminal and RStudio environments.
Full Transcript
welcome back to the data professor YouTube channel if you new here we cover about data science concepts tutorials and explainer videos and if you're into this kind of content please consider subscribing if you're wondering how to get started in our programming and how you can use our programming for data science projects then listen on so in this first video as part of a series of video we're gonna cover about the the fundamental part of a the our language so as you may know our language is very important for allowing us to do some statistical analysis of our data particularly for pre processing the data making visualization and which will also allow us to gain insights into the data and create predictive models so let's get started fire up your terminal window and fire up our so you just type in R so it's a capital R and hit enter and then here you are you're in the our environment so let's create our first variable in R so let's get started by firing up your terminal window okay and when you're in terminal you see a blinking cursor here so let's type in R capital R and so this brings you into the r programming environment so this for example type in 5 and then you will see that it also returns 5 and if we type in 5 times 6 you see that every turn study so it does multiplication here so let's try 15 / 5 so much division 15 divided by 5 so you get 3 so let's now define our first variable so let's be fine a let's assign a value of 5 and let's assign a value of 6 to be so this is the example that we have done already 5 times 6 and so let's create another variable cost C and then we're gonna have C multiply B and so this is type in C and then we're gonna get 30 because C is equal to a times B and a is equal to 5 and B is equal to 6 so 5 multiply minus 6 you get 30 so let's say that in the future a the value of a change is from 5 to 6 okay so as if that we have to define the equation C wants once more in order to get the updated value of 36 so let's say that a becomes 7 so so if you type C it still maintains the same value so we have to define it again so C equals to a times B so we're gonna define that once more and as you can see I just type in the edges press the UP button up key the arrow up arrow and it will give me the previous commands that I had tight so that I don't have to type it again okay so [Music] there you have that you have that some basic multiplication division you have defined a variable assign it with some values so let's say that you want to assign more than one value to your variable can you do that well of course so we're gonna make use of what we call a vector so a vector works pretty much like a an array in Python so if you think of it a vector and R is kind of like a bookshelf so within a bookshelf you have many shelves of course let's say that book in your book shop you have five shelves and on each shelves you have different objects so let's say that you have Apple on the first shelf you have an orange on the second shelf you have banana and the third shelf okay so it's define our variable let's call it fruits and then we're gonna have C which is when we want to define it back there so we're gonna have Apple we're gonna have orange banana tell about let's make our shelf into a three shelve books down so let's type of foods again let's say you're gonna have seen three values here apple orange banana so let's say that we want to get the values on the first shelf what do we do so you type in fruits and then you're going to use the bracket and then you're gonna type in number one so at the first position number one would be in the first position of the variable fruits so the first position and the value will return Apple so what happens if you type in fruits and any chance to balance it - yes we get orange and what happens if you type in 3 so you like to guess oh it's banana ok so there you have it you have created a variable which contains a vector of values and you have done subsetting by displaying the values in each of the shelves or each of the position in the vector and so give yourself a big 10 you have done a good job now okay so now you have created the content right inside the terminal the comment line and so now we're going to try art studio so we're gonna do the same thing in our studio so it's gonna look resemble like in the terminal so if I type in 5 I get 506 I get 6 times 5 times 6 ok 30 I assign a belly to a sign of belly to be I'll do C is equal to a times B by type C idea 30 ok so similar to what that we have previously lets you find a variable called fruits and then see the 21st element which is Apple and we're going to be fine staying at element which is orange we're gonna be third element which is banana first so we get three contents there it cooks and we got you want to get the first position foods and we want to get the second position detective first and the third position that's her okay so it works exactly like in the terminal and so now the good part is that you can also write their code and then you save it into a file so to do that you will want to click in file new file our script right and then you can type in or you could just copy what you got done here right and then you can save it into a folder of your choice I just save it into the Downloads folder I'll call it box are so no there's bad car is in capital they're unarmed so to run it you want to type in you want to click on run or you could type control-enter honey you can see it helps a bit so I can do like this again control enter control enter and you see that Apple will be returns okay thank you for watching please like subscribe and share and I'll see you in the next one but in the meantime please check out these videos
Original Description
In this R tutorial video, we will dive into R programming by taking a look at how to define variables in R.
🌟 Buy me a coffee: https://www.buymeacoffee.com/dataprofessor
⭕ Playlist:
Check out our other videos in the following playlists.
✅ Data Science 101: https://bit.ly/dataprofessor-ds101
✅ Data Science YouTuber Podcast: https://bit.ly/datascience-youtuber-podcast
✅ Data Science Virtual Internship: https://bit.ly/dataprofessor-internship
✅ Bioinformatics: http://bit.ly/dataprofessor-bioinformatics
✅ Data Science Toolbox: https://bit.ly/dataprofessor-datasciencetoolbox
✅ Streamlit (Web App in Python): https://bit.ly/dataprofessor-streamlit
✅ Shiny (Web App in R): https://bit.ly/dataprofessor-shiny
✅ Google Colab Tips and Tricks: https://bit.ly/dataprofessor-google-colab
✅ Pandas Tips and Tricks: https://bit.ly/dataprofessor-pandas
✅ Python Data Science Project: https://bit.ly/dataprofessor-python-ds
✅ R Data Science Project: https://bit.ly/dataprofessor-r-ds
⭕ Subscribe:
If you're new here, it would mean the world to me if you would consider subscribing to this channel.
✅ Subscribe: https://www.youtube.com/dataprofessor?sub_confirmation=1
⭕ Recommended Tools:
Kite is a FREE AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. I've been using Kite and I love it!
✅ Check out Kite: https://www.kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=dataprofessor&utm_content=description-only
⭕ Recommended Books:
✅ Hands-On Machine Learning with Scikit-Learn : https://amzn.to/3hTKuTt
✅ Data Science from Scratch : https://amzn.to/3fO0JiZ
✅ Python Data Science Handbook : https://amzn.to/37Tvf8n
✅ R for Data Science : https://amzn.to/2YCPcgW
✅ Artificial Intelligence: The Insights You Need from Harvard Business Review: https://amzn.to/33jTdcv
✅ AI Superpowers: China, Silicon Valley, and the New World Orde
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Data Professor · Data Professor · 13 of 60
1
2
3
4
5
6
7
8
9
10
11
12
▶
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
How a Biologist became a Data Scientist
Data Professor
WEKA Tutorial #1.1 - How to Build a Data Mining Model from Scratch
Data Professor
WEKA Tutorial #1.2 - How to Build a Data Mining Model from Scratch
Data Professor
WEKA Tutorial #1.3 - How to Build a Data Mining Model from Scratch
Data Professor
Computational Drug Discovery: Machine Learning for Making Sense of Big Data in Drug Discovery
Data Professor
Quotes #1 on Big Data and Data Science
Data Professor
Quotes #2 on Big Data and Data Science
Data Professor
Quotes #3 on Big Data and Data Science
Data Professor
Quotes #4 on Big Data and Data Science
Data Professor
Quotes #5 on Big Data and Data Science
Data Professor
Data Science 101: Starting a Data Science / Data Mining Project
Data Professor
Data Science 101: CRISP-DM - Data Mining / Data Science in 6 Steps
Data Professor
R Programming 101: How to Define Variables
Data Professor
R Programming 101: Read and Write CSV files
Data Professor
Data Science 101: Basic Command-Line for Data Science
Data Professor
Strategies for Learning Data Science in 2020 (Data Science 101)
Data Professor
Building your Data Science Portfolio with GitHub (Data Science 101)
Data Professor
R Programming 101: Setting up R programming environment (R, RStudio and RStudio.cloud)
Data Professor
Exploratory Data Analysis in R: Towards Data Understanding
Data Professor
Exploratory Data Analysis in R: Quick Dive into Data Visualization
Data Professor
Machine Learning in R: Building a Classification Model
Data Professor
Machine Learning in R: Repurpose Machine Learning Code for New Data
Data Professor
Data Science 101: Deploying your Machine Learning Model
Data Professor
Machine Learning in R: Deploy Machine Learning Model using RDS
Data Professor
Data Pre-processing in R: Handling Missing Data
Data Professor
Machine Learning in R: Speed up Model Building with Parallel Computing
Data Professor
Data Science 101: Overview of Machine Learning Model Building Process
Data Professor
Web Apps in R: Building your First Web Application in R | Shiny Tutorial Ep 1
Data Professor
Web Apps in R: Build Interactive Histogram Web Application in R | Shiny Tutorial Ep 2
Data Professor
Web Apps in R: Building Data-Driven Web Application in R | Shiny Tutorial Ep 3
Data Professor
Web Apps in R: Building the Machine Learning Web Application in R | Shiny Tutorial Ep 4
Data Professor
Web Apps in R: Build BMI Calculator web application in R for health monitoring | Shiny Tutorial Ep 5
Data Professor
Machine Learning in R: Building a Linear Regression Model
Data Professor
What programming language to learn for Data Science? R versus Python
Data Professor
How to Become a Data Scientist (Learning Path and Skill Sets Needed)
Data Professor
Using Python in R
Data Professor
Interpretable Machine Learning Models
Data Professor
Making Scatter Plots in R [Data Visualisation in R series]
Data Professor
Machine Learning in Python: Building a Classification Model
Data Professor
Compare Machine Learning Classifiers in Python
Data Professor
Hyperparameter Tuning of Machine Learning Model in Python
Data Professor
Practical Introduction to Google Colab for Data Science
Data Professor
File Handling in Google Colab for Data Science
Data Professor
Pandas for Data Science: Create and Combine DataFrames / Rename Columns
Data Professor
Machine Learning in Python: Building a Linear Regression Model
Data Professor
Machine Learning in Python: Principal Component Analysis (PCA) for Handling High-Dimensional Data
Data Professor
How to Plot an ROC Curve in Python | Machine Learning in Python
Data Professor
Installing conda on Google Colab for Data Science
Data Professor
Use native R on Google Colab for Data Science
Data Professor
How to Save and Download files from Google Colab
Data Professor
Easy Web Scraping in Python using Pandas for Data Science
Data Professor
Data Science for Computational Drug Discovery using Python (Part 1)
Data Professor
Pandas Profiling for Data Science (Quick and Easy Exploratory Data Analysis)
Data Professor
Exploratory Data Analysis in Python using pandas
Data Professor
Quick tour of PyCaret (a low-code machine learning library in Python)
Data Professor
How to Upload Files to Google Colab
Data Professor
How to Install and Use Pandas Profiling on Google Colab
Data Professor
How to Adjust the Style of Pandas DataFrame
Data Professor
How to use Bamboolib for Data Wrangling in Data Science
Data Professor
How to use Pandas Profiling on Kaggle
Data Professor
Related AI Lessons
⚡
⚡
⚡
⚡
You’re Still Paying $200/Month for AI Tools You Could Replace With a Free Local Setup Tonight
Medium · Data Science
Top 10 AI Tools Every College Student Should Know in 2026
Medium · AI
The Future of Technical Education: AI, Projects, and Industry Collaboration
Dev.to AI
I Asked Gemini AI to Preview My Haircut Before My Salon Appointment - Here’s What Happened
Medium · AI
🎓
Tutor Explanation
DeepCamp AI