Tibbles adalah inti dari struktur data tidyversedan digunakan untuk memfasilitasi tampilan dan analisis informasi dalam format yang rapi. Tibbles adalah bentuk baru dari bingkai data di mana bingkai data adalah struktur data yang paling umum digunakan untuk menyimpan kumpulan data di R.
library(tidyverse) # loading tidyverse package
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0 ✔ purrr 0.3.5
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.1 ✔ stringr 1.5.0
## ✔ readr 2.1.3 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
sample_tibble <- as_tibble(CO2) # creating a tibble named sample_tibble
print(sample_tibble)
## # A tibble: 84 × 5
## Plant Type Treatment conc uptake
## <ord> <fct> <fct> <dbl> <dbl>
## 1 Qn1 Quebec nonchilled 95 16
## 2 Qn1 Quebec nonchilled 175 30.4
## 3 Qn1 Quebec nonchilled 250 34.8
## 4 Qn1 Quebec nonchilled 350 37.2
## 5 Qn1 Quebec nonchilled 500 35.3
## 6 Qn1 Quebec nonchilled 675 39.2
## 7 Qn1 Quebec nonchilled 1000 39.7
## 8 Qn2 Quebec nonchilled 95 13.6
## 9 Qn2 Quebec nonchilled 175 27.3
## 10 Qn2 Quebec nonchilled 250 37.1
## # … with 74 more rows
library(tidyverse)
name <- c("ILHAM", "KURNIAWAN", "DEDDY", "KORBUZER", "SOKOWI", "DODO")
marks_in_Math <- c(91, 85, 92, 89, 90, 93)
marks_in_Java <- c(89, 91, 88, 91, 89, 87)
Fav_color <- c("Pink", "Red", "Yellow", "Green", "White", "Blue")
students <- tibble(name, marks_in_Math, marks_in_Java, Fav_color)
print(students)
## # A tibble: 6 × 4
## name marks_in_Math marks_in_Java Fav_color
## <chr> <dbl> <dbl> <chr>
## 1 ILHAM 91 89 Pink
## 2 KURNIAWAN 85 91 Red
## 3 DEDDY 92 88 Yellow
## 4 KORBUZER 89 91 Green
## 5 SOKOWI 90 89 White
## 6 DODO 93 87 Blue
library(tidyverse)
name <- c("ILHAM", "KURNIAWAN", "DEDDY", "KORBUZER", "SOKOWI", "DODO")
marks_in_Math <- c(91, 90, 91, 85, 90, 92)
marks_in_Java <- c(91, 91, 92, 91, 89, 93)
Fav_color <- c("Pink", "Red", "Yellow", "Green", "White", "Blue")
students <- tibble(name, marks_in_Math, marks_in_Java, Fav_color)
students$Fav_color
## [1] "Pink" "Red" "Yellow" "Green" "White" "Blue"
students$marks_in_Math
## [1] 91 90 91 85 90 92