#Source: https://r4ds.had.co.nz/tibbles.html
library(tibble)
library(tidyverse)
is.data.frame(iris)
as_tibble(iris)
is.data.frame(as_tibble(iris))
tibble(
x = 3:15,
y = 2,
z = x ^ 2 + y
)
############
tb <- tibble(
`:)` = "smile",
` ` = "space",
`2023` = "number"
)
tb
############
tribble(#zwroc uwagę na inny sposób definicji danych w tabeli
~x, ~y, ~z,
"a", 20, 1.6,
"b", 10, 5.5
)
########################
?lubridate
lubridate::now()
lubridate::today()
runif(1) * 86400
helper1<-tibble(
a = lubridate::now() + runif(1e3) * 86400,
b = lubridate::today() + runif(1e3) * 30,
c = 1:1e3,
d = runif(1e3),
e = sample(letters, 1e3, replace = TRUE)
)
helper1
helper1 %>% print(n=12)
helper1 %>% print(n=Inf)
#######################################
nycflights13::flights %>%
print(n = 10, width = Inf)
#######################################
#Opcje, które można ustawić według własnych potrzeb
#options(tibble.print_max = n, tibble.print_min = m)
options(tibble.print_max = 4)
nycflights13::flights %>%
print(width = Inf)
options(tibble.print_max = 4)
options(tibble.width = Inf)
##################
nycflights13::flights %>%
View()
###############
df <- tibble(
kolumna1 = 1:5,
kolumna2 = rnorm(5)
)
df
df$kolumna1
df[["kolumna1"]]
df[[1]]
df %>% .$kolumna1
df %>% .[["kolumna1"]]
###########
tb_2<- tibble(
x = -0.7+1:5,
y = 3+rnorm(5)
)
tb_2
class(tb_2)
is_tibble(tb_2)
is.data.frame(tb)
as.data.frame(tb)
class(as.data.frame(tb))
################
vignette("tibble")