A fantastic feature that was added to the R language by Hadley Wickham is the modern re-imagination of DataFrames, commonly known as tibbles or tbl_df. Tibbles work like lazy DataFrames. They don't perform a lot of new actions, but purify the older ones by keeping the essential elements and discarding the less effective ones.
Using lazy DataFrames is a way to query data where and when required. It creates a logical plan then return computed data with either the
pull()
,collect()
, oras.data.frame()
function.
This is how we can create a tibble:
# using this method to create tibblestibble()#oras_tibble()
Let’s elaborate on some coding examples that are associated with the functions given above.
tibble()
functionlibrary(tibble)mytibble= tibble(x = 1:4, y = 2, z = x ^ 3 + y)print(mytibble)
tibble()
function and pass the vector values to create a DataFrame with four rows and three columns.as_tibble()
functionlibrary(tibble)mydata <- data.frame(x = 4:8, y = letters[4:8], z = Sys.Date() - 4:8)print(mydata)mytibble= as_tibble(mydata)print(mytibble)
mydata
and add values to the three columns and five rows of the DataFrame. Each row has an integer digit starting from 4, an alphabetical letter that corresponds to that number, and the system date after subtracting the respective int value.as_tibble()
function and assign it to the mytibble
variable.