Skip to content

Latest commit

 

History

History
58 lines (55 loc) · 2.36 KB

6.Tibbles.md

File metadata and controls

58 lines (55 loc) · 2.36 KB

Tibbles

  • A tidyverse package
  • Can be called modern dataframes
  • Does Less, Complains more, i.e, forces you to confront problems
  • Leads to cleaner more expressive code
  • Comes with enhanced print() thus making it easier to use large datasets containing complex objects
  • Any function working with dataframes will work with tibbles
  • Tibbles: The simple data frame?

    • Never changes type of inputs
    • Never changes the names of variables
    • Never create row names
    • Possible column names are available i.e., can rename column other than respective variable name and with variable rule bending by surroung then with backticks(`)

Transposed Tibble or tribble

  • function name tribble()
  • customised for data entry in code like column headings defined by formulae or seperated by commas
  • Makes it possible to lay out small amount of data in easy to read form
  • Comes with refined print()
    • Shows only first 10 rows
    • Shows all columns that fit on the screen
    • Makes it easier to work with large data
    • Each column reports its name and type which is similar to str() in dataframes

Resources for tibbles:

Codes related to Tibbles

#installing tidyverse package before working with tibbles
install.packages("tidyverse")

How to convert to a tibble

library(tibble)
as_tibble(iris) #iris is predeined data frame or data package in R and as_tibble converts dataframe to tibble

image

How to define a tibble

  • As tibble is modern Data Frame it allows you to give uneven length of vectors as input and then it matches the length automatically
  • You can have columns as arithmetics of other columns
  • You can name your columns anything like emojis(the one made with keyboard combinations), invalid combination of characters, etc
library(tibble)
tibble(
  x = 1:5,
  ` ` = 6,
  `;)` = x + ` `
)

image

Transposed Tibble or Tribble

  • Anything followed by tint(~) is the name of the column
library(tibble)
tribble(~x, ~y, ~z, "a", T, 3.6, "1", F, 5)

image