Need up to 30 seconds to load.
in this video you're going to be
learning how to create
variables that could house a single
value and also
a variable that could house multiple
values
which is also known as a list or an
array
in other programming language and so
without further ado
we're starting right now
okay so the first thing that you want to
do is open up the terminal
and then you want to type in r enter and
then we're in the terminal
version of r
and so let's start by creating a
variable let's say
a variable called color and then we're
going to be assigning a value of
blue and notice here that to create a
variable
we need a less than sign and then a dash
and so that is
equivalent to an equal symbol in other
programming language
such as python okay and if i type in
color again
i will get the value of blue which i
have assigned it just a moment ago
and if i update the value to be red
by assigning it again to the same
variable and if i type in color
it will now be updated to red and so
notice that in the first time here
i initially assigned the value of blue
but then if i assign it again
to the same variable the color will be
updated to red
okay so let's say that i would like to
create now a variable
that contains multiple values let's say
we create a variable called colors and
then
less than dash this is equivalent to
an equal right and therefore i will be
assigning it to be
we're going to make use of a c function
so blue
red green and notice that i
will have to close it with the closing
parenthesis and so
notice that we have a c and then a
opening and closing parenthesis
and then each element here will be
denoted by the
single quotation or also a double
quotation
so depending on your own preference you
could have either
single or double quotation but don't mix
and match right don't start by
single ending with a double okay so have
consistency here
and notice that you have a comma to
separate the values
and let's hit on enter and let's type in
colors
and so now you're going to see the three
values that you have assigned to it
in the c function here and so the same
concept also applies to numbers
so let's say that we create a variable
called scores
and then we have also the c function
again and then we have the
values of 100 80 90.
and then we hit on enter and then we
type in scores
and then we get the values that we have
assigned to it 180 and 90.
okay so now that we are able to create a
variable
that contains several values let's now
try to select particular position or
location
in the variable so for example if i
would like to select the color blue
red or green specifically i could do the
following let me show you
i could type in colors and i'll use the
bracket
and inside the bracket i'm going to put
a number of one and see what happens
and so you see that when i put a number
of one it will be selecting the color
which is at the first position
and if i do the same thing by changing
the number to two
i will be getting the number or the
color at the
position number two which is red and if
i do the same thing
and change the number to three i will be
getting can you guess which color
you're correct i'm going to get the
green color okay so
position one two three and the bracket
will be kind of like a
we can call it as a slicing mechanism
where we will be essentially
slicing the particular variable into
several segments whereby we could select
the particular segment
by specifying the exact number that we
would like to select
so as i've already shown you to select
acquisition one
two or three okay so congratulations
you're now able to create variables
containing a single value
several values and also you're able to
select particular
members or segment in the variable and
so please stay tuned for the next
tutorial
and please support the channel by
smashing the like button
subscribing if you haven't already and
also make sure to hit on the
notification bell so that you will be
notified
of the next video and as always the best
way to learn data science
is to do data science and please enjoy
the journey