Characters and Logicals in R

365 Careers
A free video tutorial from 365 Careers
Creating opportunities for Business & Finance students
4.5 instructor rating • 66 courses • 1,201,022 students

Learn more from the full course

R Programming for Statistics and Data Science 2020

R Programming for Data Science & Data Analysis. Applying R for Statistics and Data Visualization with GGplot2 in R

06:24:22 of on-demand video • Updated June 2020

  • Learn the fundamentals of programming in R
  • Work with R’s conditional statements, functions, and loops
  • Build your own functions in R
  • Get your data in and out of R
  • Learn the core tools for data science with R
  • Manipulate data with the Tidyverse ecosystem of packages
  • Systematically explore data in R
  • The grammar of graphics and the ggplot2 package
  • Visualise data: plot different types of data & draw insights
  • Transform data: best practices of when and how
  • Index, slice, and subset data
  • Learn the fundamentals of statistics and apply them in practice
  • Hypothesis testing in R
  • Understand and carry out regression analysis in R
  • Work with dummy variables
  • Learn to make decisions that are supported by the data!
  • Have fun by taking apart Star Wars and Pokemon data, as well some more serious data sets
English [Auto] Obreht everybody in the previous lesson we learned about the integer type and the double typing are here. We will tackle characters and logical vectors. Let's get to it characters. These are vectors that can store text data. You can save a single character into a character vector or longers rings by putting them in quotation marks like this. Now if I check what basic type this car object is I will tell me that it's a character right. Right. OK. Let me do another example see if you can figure out what's happening there. Care to. Because I don't want to overwrite my car object. And then the answer to Life the Universe and Everything is 42. Chicot's type character. Ha. But it has the number 42 in it doesn't it. And didn't I say earlier that vectors can only store elements of the same basic type. Yes it did. What's happening here then. Well we put the number 42 in quotation marks. Effectively we told our that it is actually a characters ring and not a numerical value. You see the elements of a character vector are called strings and they are not restricted to only being letters. You can define a string of numbers or symbols if you wish. OK let's take a look at logical variables. Now logical vectors store boolean data or true and false values are considers T and F to be shorthand for true and false. So they are interchangeable and you can use either or both. Let's create a logical vectoring call Lead let's call it Spock after the ultimate superhero of logical reasoning. Mr Spock from the Star Trek universe. Notice that I don't to use quotation marks here and everything is in capital letters. This is a good moment to mention that R is a case sensitive language and you want to be careful when calling objects or functions to match their casings. Let's check the type of Spock it is logical. That sounds about right or right. As I mentioned there are two more data types. Complex and raw. But they are extremely unlikely to be used in data analysis. If you want to learn more about them for the sake of being thoroughly informed feel free to consult the resources for this lesson or type into your script. Question mark is not complex and run the line. This is the same as typing help and parsing is not complex in parentheses and both open up the helped up on that. Is that complex function. You can do the same for the raw basic type do you fantastic. Well that's it for this lesson you learned a lot about data types and some new functions. Try to recall their names and what they're used for. Next will take a little break from long lessons. Talk about coersion Rousan are it's a life lesson so see you there. Bye for now and live cold and prosper.