R Finance Tutorial: Basic Data Types

Publié le: 31 mars 2017
sur la chaîne: DataCamp
1,039
9

Like and comment this video if you enjoyed it!

About the course: Learning R can be intimidating, especially without concrete examples you might see in the real world. In this finance oriented introduction to R, you will learn essential data structures such as lists and data frames and have the chance to apply that knowledge directly to financial examples. By the end of the course, you will feel comfortable with the basics of manipulating your data to perform financial analysis in R. Take this course: https://www.datacamp.com/courses/intr...


Now that you're familiar with how to run commands in R, let's get a bit more technical into exactly what types of data you have been manipulating. There are a number of basic atomic data types in R. Here are the most common ones.

Numeric data are decimal numbers like 42.5. Numeric data could be stock prices, cash flow, or income. A special type of numeric data is integers. Integers are whole numbers that do not have a decimal place. By default, whole numbers like 5 are stored as numeric data unless you specifically tell R that you want it to store 5 as an integer. To do this, add a capital L after the number. You will almost always use numerics over integers in R, so this default behavior is nothing to worry about.

Characters, also called strings, are text values such as "Hello world", or "forty". Character data could be a sequence of names, or categories for your data, or even credit rating for bonds. Note the quotation marks telling R that you are giving it character data. Even numbers can be stored as character data if you put it in quotation marks.

And finally, Logicals are the so called boolean values of TRUE and FALSE. R requires that true and false be capitalized, so this would cause an error. Technically, NA, to denote a missing value, is also a logical, but we won't go deep into that here.

So far, you have stored numeric data in variables, but you could have just as easily stored logical or character data in a variable as well. Here, the logical TRUE is assigned to my_answer and the word "carrots" is assigned to food.

Given a variable, you can use R to determine what data type it is with class(). Using class on my_answer returns "logical", telling you that the my_answer variable contains a logical data type. class() is what is known as a function. You will see a number of useful functions throughout the course, but for now, you can think of them as a black box, where you pass in some kind of input, the function calculates some value, and presents it to you as output. You can use class() to see the difference in type between the numeric and integer versions of 5.

Let's find out what you learned, head over to the next exercise to try out your knowledge of data types.


Sur cette page du site, vous pouvez voir la vidéo en ligne R Finance Tutorial: Basic Data Types durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur DataCamp 31 mars 2017, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 1,039 fois et il a aimé 9 téléspectateurs. Bon visionnage!