Closed tylerlittlefield closed 4 years ago
I made some changes, hp_dataframe has title set to "Hierplane" by default (like before). Also, hp_spacyr has settings/... params added:
library(hierplane)
df_dataframe <- hp_dataframe(
.data = df,
settings = hierplane_settings(attributes = c("height", "age"))
)
hierplane(df_dataframe, theme = "dark")
df <- structure(
list(
parent_id = c("Bob", "Bob", "Bob", "Bob", "Angelica", "Bob"),
child_id = c("Bob", "Angelica", "Eliza", "Peggy", "John", "Jess"),
child = c("Bob", "Angelica", "Eliza", "Peggy", "John", "Jess"),
node_type = c("gen1", "gen2", "gen2", "gen2", "gen3", "ext"),
link = c("ROOT", "daughter", "daughter", "daughter", "son", "cousin"),
height = c("100 cm", "100 cm", "90 cm", "50 cm", "10 cm", "70 cm"),
age = c("60 yo", "30 yo", "25 yo", "10 yo", "0.5 yo", "150 yo")
),
row.names = c(NA, -6L),
class = c("data.frame")
)
One more change to class name:
hierplane::hp_spacyr("sam likes boats")
#> <hierplane_tree object: from hp_spacyr>
Please let me know if there is anything else I need to address š
Works perfectly now! The only thing is that we need to export spacyr_default()
(also may need to rename to something more indicative that this defines the hierplane settins for spacyr hps). We can address this in a different pr. I'll open a ticket for documentation.
Also need to export %>%
:D
Approving and merging!
# create a hierplane object from dataframe input
df_dataframe <- hp_dataframe(
.data = df,
title = "Family",
settings = hierplane_settings(
attributes = c("height", "age")
) %>% add_styles(link_to_positions = list(cousin = "right"))
)
hierplane(df_dataframe)
df_spacyr <- hp_spacyr("Bob says hi",
settings =
hierplane:::spacyr_default() %>%
add_styles(
link_to_positions =
list(
nsubj = "left",
intj = "right"
)
)
)
hierplane(df_spacyr, theme = "dark")
hp_
functions addedExamples
Hierplane objects print differently now, they show that they are a hierplane object and from what function they were created:
Then to render we just call
hierplane()
:If you want to print the json or the list, just use
jsonlite
:With
spacyr
we do this:With styles:
This closes #21