From the course: R for Data Science: Analysis and Visualization

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Data types and structures

Data types and structures

- [Instructor] I mentioned earlier, that when you save some data into an object or a variable in R, you don't have to declare the type. Now, R does have data types and you can specify them, but it does certain things by default. Let me show you how this works. I'm going to come down here and I'm going to create a variable called n1 for numeric variable one, and I'm going to assign the value of 15 to it. Okay. You can see that the 15 has showed up over here. I'm going to have it display that value down here in the console, and then I'm going to ask for the type of, and notice it tells me that it is double. In other languages, if you give numbers without a decimal, it will assume that it is an integer value. Well, R doesn't do that. It assumes double precision by default. Here, I'll use one that says 1.5 and I'll save it to n2 for a numeric two, and then we can see this n5, and I get its type and it is also double. So…

Contents