Create a RelDataModel object from column names of data frames
Source:R/df_to_model.R
df_to_model.Rd
Create a RelDataModel object from column names of data frames
Usage
df_to_model(..., list = character(), pos = -1, envir = as.environment(pos))
Arguments
- ...
the data frame objects, as names (unquoted) or character strings (quoted)
- list
a character vector naming data frame objects
- pos
where to get the objects. By default, uses the current environment. See ‘details’ for other possibilities.
- envir
the environment to use. See ‘details’.
Value
A RelDataModel object.
Details
The pos argument can specify the environment from which to get the objects in any of several ways: as an integer (the position in the search list); as the character string name of an element in the search list; or as an environment. The envir argument is an alternative way to specify an environment, but is primarily there for back compatibility.
Examples
## Read data files ----
to_read <- list.files(
system.file("examples/HPO-subset", package="ReDaMoR"),
full.names=TRUE
)
hpo_tables <- list()
for(f in to_read){
hpo_tables[[sub("[.]txt$", "", basename(f))]] <- readr::read_tsv(f)
}
#> Rows: 89 Columns: 2
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: "\t"
#> chr (2): id, alt
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Rows: 972 Columns: 2
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: "\t"
#> chr (2): id, descendant
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Rows: 2594 Columns: 3
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: "\t"
#> chr (2): db, hp
#> dbl (1): id
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Rows: 2337 Columns: 4
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: "\t"
#> chr (2): db, synonym
#> dbl (1): id
#> lgl (1): preferred
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Rows: 1903 Columns: 3
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: "\t"
#> chr (2): db, label
#> dbl (1): id
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Rows: 500 Columns: 4
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: "\t"
#> chr (3): id, name, description
#> dbl (1): level
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Rows: 95 Columns: 2
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: "\t"
#> chr (2): id, parent
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Rows: 2 Columns: 2
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: "\t"
#> chr (1): url
#> date (1): current
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Rows: 730 Columns: 3
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: "\t"
#> chr (3): id, synonym, type
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Build the model from a list of data frames ----
new_model <- df_to_model(
list=names(hpo_tables), envir=as.environment(hpo_tables)
)
## Plot the model ----
new_model %>%
auto_layout(lengthMultiplier=250) %>%
plot()