Learn about the R Data Types _ R Tutorial #3

The Four Common Data Types in Python

When working with data science projects in Python, it's essential to understand the four common data types that are frequently used. These data types include numeric, logical, character, and complex numbers.

Numeric Data Type

-----------------

In Python, the first data type is the numeric data type. This includes integers, floats, and more. For example, if we create a variable `a` and assign it a value of 2, we can check its data type by using the `class()` function. As shown in the script, `class(a)` returns `numeric`, indicating that `a` is indeed an integer.

Similarly, if we create another variable `b` and assign it a value of 3.14, which is a floating-point number, we can check its data type using the same method. The result is again `numeric`. However, when we use the `l` suffix after the number, such as in `5L`, it changes the data type to integer.

Logical Data Type

-----------------

The second data type is the logical data type, which includes boolean values (True or False) and more complex logical expressions. For instance, if we create a variable `e` with the value `true` (in all caps), we can check its data type using the `class()` function.

Similarly, if we create another variable `f` with the value `2`, which is assigned to `a`, we can assign `f` to have the same value as `a`. However, when we compare `a` and `f` using the equality operator (`==`), the result is indeed `True`.

Character Data Type

-----------------

The third data type is the character data type. This includes strings of single characters, such as letters or numbers.

For example, if we create a variable `g` with an "a" inside quotation marks, we can check its data type using the `class()` function. The result is indeed `character`. However, without the quotation marks, `g` is simply a variable.

Notice that when we assign a value to `g`, it takes on the same value as the variable `a`, which is 2 (without the quotation marks). This means that if we use single quotation marks or double quotation marks inside the character data type, it treats them as literal characters rather than values.

Complex Data Type

----------------

The fourth and final data type in Python is the complex data type. This includes numbers with imaginary parts, such as `5 + 5i`.

For example, if we create a variable `m` with the value `5 + 5i`, we can check its data type using the `class()` function.

R Programming Language

----------------------

In R, the four common data types are also frequently used. When launching the R command prompt, you can use the keyboard shortcut `Ctrl + L` to clear the screen before starting your code.

To check the data type of a variable in R, you can use the `class()` function. For instance, if we create a variable `a` with the value 2, we can use `class(a)` to confirm that its data type is indeed numeric.

Similarly, if we create another variable `b` with the value 3.14, which is a floating-point number, we can use `class(b)` to confirm that its data type is again numeric.

Using the integer suffix `L` after the number changes the data type to integer, as shown in the example using the variable `c`.

Logical Data Type

-----------------

R also supports logical data types, which include boolean values (TRUE or FALSE). For instance, if we create a variable `e` with the value `TRUE`, we can use `class(e)` to confirm that its data type is indeed logical.

Similarly, if we create another variable `f` with the value 2, which is assigned to `a`, we can assign `f` to have the same value as `a`. However, when we compare `a` and `f` using the equality operator (`==`), the result is indeed `TRUE`.

Character Data Type

-----------------

R also supports character data types, which include strings of single characters or multiple words.

For example, if we create a variable `g` with an "a" inside quotation marks, we can use `class(g)` to confirm that its data type is indeed character. However, without the quotation marks, `g` is simply a variable.

Notice that when we assign a value to `g`, it takes on the same value as the variable `a`, which is 2 (without the quotation marks). This means that if we use single quotation marks or double quotation marks inside the character data type, it treats them as literal characters rather than values.

Complex Data Type

----------------

R also supports complex data types, which include numbers with imaginary parts. For instance, if we create a variable `m` with the value `5 + 5i`, we can use `class(m)` to confirm that its data type is indeed complex.

By understanding these four common data types in Python and R, you'll be better equipped to work with different types of data and perform more efficient coding.

"WEBVTTKind: captionsLanguage: eni'm going to cover the six data types in r and we're starting right now so a few minutes ago i've tweeted about the r data types and so i've summarized it as follows so the first data type in r is numeric and numeric could be an integer it could also be a decimal a floating point or a double and the second data type is an integer and so an integer will have to be specified by adding a l at the end and so i'm going to show you in just a moment if we type in 5 or if you type in 5l what's the difference between those two and the third data type is logical and biological is true or false so it's the condition and the fourth data type is character and so if you're coming from python you might know this as string and so character could be a single character it could either be using a single quotation mark or it could be using a double quotation mark but don't mix the two don't begin with a single quotation mark and end with a double quotation mark so be consistent and have either a single quotation mark or double quotation mark and two words as in data science is also a character and even the number 100 if you put it inside a quotation mark it'll be a character as well the fifth data type is complex complex number and so an example would be 5 5i and the sixth data type is raw and for example the words data science if we are to make it into a raw data type it's going to be storing the information as follows here 64 61 until 65. so you could use the character to raw function in order to convert data science into this format of bar of raw okay so the four common data types that we're going to be seeing a lot when you're doing data science projects is the first four that i have listed here okay so let's launch the r prompt so if you have already installed r you can now launch the r command prompt and so you could either go to terminal or you could go to the powershell or you could even go into your r studio okay but i'm going to use the r command prompt here so i'm typing an r in the terminal okay and then i'm going to get the r loaded and in order to clear all of this message that you see here i'm going to type command l on my macbook or if you're on a windows or a ubuntu you could type in ctrl l okay so using the keyboard shortcut ctrl l or command l like so and it will clear the screen so this comes in handy when you're typing information in and then you want to clear it command l okay okay so let's start with the first data type which is numeric so for example if i'm creating a variable called a and then i'm assigning a value of 2 and let's see if i want to determine the data type i'm going to type in class and then a and then they get numeric and let me try again if i say b is 3.14 class b is also numeric and let's create a c variable and let's say i'm assigning a value of 5 l which is the integer see the class and so now is an integer however if we have the same number but without the l it is a numeric and so in order to make it in integer form you have to add l after the number okay so the third data type is the logical for example if we say like true class of e would be logical okay so the same thing for false like for example if you say a is equal to b it's not it's false okay so what if i say i created another variable f equals to 2 and let's say a is equal to f is that true yes it's true because a and f both has a value of two okay so moving on to the fourth data type which is character let me create a variable g and i'll put an a in here but with the quotation and so class so it's character but if i say g and a like that let's see what happens so what it will essentially do is that it's going to assign the value of 2 which is already assigned to a and it's going to assign it to g and therefore because a had a value of 2 as shown above here and we're assigning g to have the same value as the variable a which is two so notice that with quotation it is a character but without quotation it is a variable okay so if you have two words it is also a character if you have a number inside the quotation mark it is also a character if you have a double quotation it's going to be also a character however let's try out using a mix match of double quotation and then ending with a single quotation so you're going to see that there's going to be an error so it is expecting the code to be unfinished okay so in order to abort this i have to hit the keyboard combination of control c okay let's move on to the complex data type so example is 5 plus 5i class so it is complex and the last data type number six we're going to use the character to raw function and then we're putting in data science as the input argument class m and so you see that the data type is wrong so if you're finding value in this video please give it a thumbs up subscribe if you haven't already and make sure to smash 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 journeyi'm going to cover the six data types in r and we're starting right now so a few minutes ago i've tweeted about the r data types and so i've summarized it as follows so the first data type in r is numeric and numeric could be an integer it could also be a decimal a floating point or a double and the second data type is an integer and so an integer will have to be specified by adding a l at the end and so i'm going to show you in just a moment if we type in 5 or if you type in 5l what's the difference between those two and the third data type is logical and biological is true or false so it's the condition and the fourth data type is character and so if you're coming from python you might know this as string and so character could be a single character it could either be using a single quotation mark or it could be using a double quotation mark but don't mix the two don't begin with a single quotation mark and end with a double quotation mark so be consistent and have either a single quotation mark or double quotation mark and two words as in data science is also a character and even the number 100 if you put it inside a quotation mark it'll be a character as well the fifth data type is complex complex number and so an example would be 5 5i and the sixth data type is raw and for example the words data science if we are to make it into a raw data type it's going to be storing the information as follows here 64 61 until 65. so you could use the character to raw function in order to convert data science into this format of bar of raw okay so the four common data types that we're going to be seeing a lot when you're doing data science projects is the first four that i have listed here okay so let's launch the r prompt so if you have already installed r you can now launch the r command prompt and so you could either go to terminal or you could go to the powershell or you could even go into your r studio okay but i'm going to use the r command prompt here so i'm typing an r in the terminal okay and then i'm going to get the r loaded and in order to clear all of this message that you see here i'm going to type command l on my macbook or if you're on a windows or a ubuntu you could type in ctrl l okay so using the keyboard shortcut ctrl l or command l like so and it will clear the screen so this comes in handy when you're typing information in and then you want to clear it command l okay okay so let's start with the first data type which is numeric so for example if i'm creating a variable called a and then i'm assigning a value of 2 and let's see if i want to determine the data type i'm going to type in class and then a and then they get numeric and let me try again if i say b is 3.14 class b is also numeric and let's create a c variable and let's say i'm assigning a value of 5 l which is the integer see the class and so now is an integer however if we have the same number but without the l it is a numeric and so in order to make it in integer form you have to add l after the number okay so the third data type is the logical for example if we say like true class of e would be logical okay so the same thing for false like for example if you say a is equal to b it's not it's false okay so what if i say i created another variable f equals to 2 and let's say a is equal to f is that true yes it's true because a and f both has a value of two okay so moving on to the fourth data type which is character let me create a variable g and i'll put an a in here but with the quotation and so class so it's character but if i say g and a like that let's see what happens so what it will essentially do is that it's going to assign the value of 2 which is already assigned to a and it's going to assign it to g and therefore because a had a value of 2 as shown above here and we're assigning g to have the same value as the variable a which is two so notice that with quotation it is a character but without quotation it is a variable okay so if you have two words it is also a character if you have a number inside the quotation mark it is also a character if you have a double quotation it's going to be also a character however let's try out using a mix match of double quotation and then ending with a single quotation so you're going to see that there's going to be an error so it is expecting the code to be unfinished okay so in order to abort this i have to hit the keyboard combination of control c okay let's move on to the complex data type so example is 5 plus 5i class so it is complex and the last data type number six we're going to use the character to raw function and then we're putting in data science as the input argument class m and so you see that the data type is wrong so if you're finding value in this video please give it a thumbs up subscribe if you haven't already and make sure to smash 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 journeyi'm going to cover the six data types in r and we're starting right now so a few minutes ago i've tweeted about the r data types and so i've summarized it as follows so the first data type in r is numeric and numeric could be an integer it could also be a decimal a floating point or a double and the second data type is an integer and so an integer will have to be specified by adding a l at the end and so i'm going to show you in just a moment if we type in 5 or if you type in 5l what's the difference between those two and the third data type is logical and biological is true or false so it's the condition and the fourth data type is character and so if you're coming from python you might know this as string and so character could be a single character it could either be using a single quotation mark or it could be using a double quotation mark but don't mix the two don't begin with a single quotation mark and end with a double quotation mark so be consistent and have either a single quotation mark or double quotation mark and two words as in data science is also a character and even the number 100 if you put it inside a quotation mark it'll be a character as well the fifth data type is complex complex number and so an example would be 5 5i and the sixth data type is raw and for example the words data science if we are to make it into a raw data type it's going to be storing the information as follows here 64 61 until 65. so you could use the character to raw function in order to convert data science into this format of bar of raw okay so the four common data types that we're going to be seeing a lot when you're doing data science projects is the first four that i have listed here okay so let's launch the r prompt so if you have already installed r you can now launch the r command prompt and so you could either go to terminal or you could go to the powershell or you could even go into your r studio okay but i'm going to use the r command prompt here so i'm typing an r in the terminal okay and then i'm going to get the r loaded and in order to clear all of this message that you see here i'm going to type command l on my macbook or if you're on a windows or a ubuntu you could type in ctrl l okay so using the keyboard shortcut ctrl l or command l like so and it will clear the screen so this comes in handy when you're typing information in and then you want to clear it command l okay okay so let's start with the first data type which is numeric so for example if i'm creating a variable called a and then i'm assigning a value of 2 and let's see if i want to determine the data type i'm going to type in class and then a and then they get numeric and let me try again if i say b is 3.14 class b is also numeric and let's create a c variable and let's say i'm assigning a value of 5 l which is the integer see the class and so now is an integer however if we have the same number but without the l it is a numeric and so in order to make it in integer form you have to add l after the number okay so the third data type is the logical for example if we say like true class of e would be logical okay so the same thing for false like for example if you say a is equal to b it's not it's false okay so what if i say i created another variable f equals to 2 and let's say a is equal to f is that true yes it's true because a and f both has a value of two okay so moving on to the fourth data type which is character let me create a variable g and i'll put an a in here but with the quotation and so class so it's character but if i say g and a like that let's see what happens so what it will essentially do is that it's going to assign the value of 2 which is already assigned to a and it's going to assign it to g and therefore because a had a value of 2 as shown above here and we're assigning g to have the same value as the variable a which is two so notice that with quotation it is a character but without quotation it is a variable okay so if you have two words it is also a character if you have a number inside the quotation mark it is also a character if you have a double quotation it's going to be also a character however let's try out using a mix match of double quotation and then ending with a single quotation so you're going to see that there's going to be an error so it is expecting the code to be unfinished okay so in order to abort this i have to hit the keyboard combination of control c okay let's move on to the complex data type so example is 5 plus 5i class so it is complex and the last data type number six we're going to use the character to raw function and then we're putting in data science as the input argument class m and so you see that the data type is wrong so if you're finding value in this video please give it a thumbs up subscribe if you haven't already and make sure to smash 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\n"