Introduction to R: Factors

Поделиться
HTML-код
  • Опубликовано: 27 окт 2024
  • Factors in R are data structures that store categorical data. The default behavior for the the data frame constructor function and various data loading functions in R is to convert character data to factors. Various statistical, predictive modeling and graphic operations in R recognize factors as categorical data, but this automatic conversion is often undersirable, especially if you need to clean your data prior to analysis. To suppress this behavior, pass the extra argument "stringsAsFactors = FALSE" when constructing data frames or loading data with the standard read.csv() built in family of functions.
    This is lesson 9 of a 30-part introduction to the R programming language for data analysis and predictive modeling. Link to the code notebook below:
    Introduction to R: Data Frames www.kaggle.com...
    This guide does not assume any prior exposure to R, programming or data science. It is intended for beginners with an interest in data science and those who might know other programming languages and would like to learn R.
    I will create the videos for this guide such that you should be able to learn a lot just watching on RUclips, but to get the most out of the guide, it is recommended that you create a Kaggle account so that you can fork and edit each lesson so that you can follow along and run code yourself.
    Follow DataDaft on social media for news and updates:
    Twitter: / datadaft
    Introduction to R Playlist:
    • Introduction to R

Комментарии • 9

  • @marcoventura9451
    @marcoventura9451 2 года назад +4

    So clear and so neat! Great video, great teacher. Thank You.

  • @AmritaPBB
    @AmritaPBB 2 года назад

    very well explained...i never understood factors before this

  • @tree3868
    @tree3868 2 года назад

    Great video sir! It really helps me out!

  • @RPenahli
    @RPenahli 4 года назад +1

    Great videos Sir!

  • @TheEverydayAnalyst
    @TheEverydayAnalyst 4 года назад +1

    Are factors more memory efficient or more performant than character type? Why should we switch between them?

    • @DataDaft
      @DataDaft  4 года назад +3

      Factors are mainly useful because by encoding categorical variable as integers they can be used in many statistical functions that expect numbers. For instance, you can run a linear regression model on a factor or use factors as predictors for machine learning but you can't pass character/string data to many statistical, modeling and plotting functions in R.

    • @TheEverydayAnalyst
      @TheEverydayAnalyst 4 года назад +1

      @@DataDaft Got it! Thanks for replying so quickly :)
      The content flow is just amazing. ✌️
      Have a great day.

  • @rupalhatkar4695
    @rupalhatkar4695 3 года назад

    how can I assign levels to multiple columns of a data frame using factor?

  • @ev1836
    @ev1836 3 года назад

    what about labels? whats the difference between levels and labels?