library(dplyr)
# --- Successful Example ---
# Create a chronicle object whose value is a data frame
starwars_chronicle <- starwars %>%
record(filter)(species == "Human") %>%
bind_record(record(select), name, height, mass)
# Now, you can use as.data.frame() directly on the chronicle object
sw_df <- as.data.frame(starwars_chronicle)
class(sw_df)
head(sw_df)
# --- Error Example ---
# Create a chronicle object whose value is a number
numeric_chronicle <- record(sqrt)(100)
# This will fail with a specific error message because a number
# cannot be turned into a data frame.
try(as.data.frame(numeric_chronicle))
Run the code above in your browser using DataLab