A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/patperry/r-frame below:

patperry/r-frame: Flexible data frames (R package)

frame is an R package providing a dataset type analogous to a data.frame supporting two major extensions: (1) associate keys with one or more components to each row; (2) use matrix-like objects as columns, including nested datasets.

frame is available on CRAN. To install the latest released version, run the following command in R:

### install.packages("frame") # not yet, actually

To install the latest development version, run the following:

devtools::install_github("patperry/r-frame")

The dataset type is like a data.frame but it allows matrix-like columns, including sparse matrices and nested datasets.

# dataset with a sparse matrix column
(x <- dataset(age = c(35, 70, 12, 42),
              color = c("red", "blue", "black", "green"),
              set = Matrix::sparseMatrix(i = c(1, 1, 2, 3, 3, 4),
                                         j = c(3, 2, 1, 3, 2, 1),
                                         x = c(2.8, -1.3, 7.1, 0.1, -5.1, 3.8),
                                         dimnames = list(NULL, c("a", "b", "c")))))
#>             ════set═════
#>   age color   a    b   c
#> 1  35 red   0.0 -1.3 2.8
#> 2  70 blue  7.1  0.0 0.0
#> 3  12 black 0.0 -5.1 0.1
#> 4  42 green 3.8  0.0 0.0

# dataset with a dataset column
(y <- dataset(value = rnorm(4), nested = x))
#>              ════════nested════════
#>                        ════set═════
#>        value age color   a    b   c
#> 1  1.2629543  35 red   0.0 -1.3 2.8
#> 2 -0.3262334  70 blue  7.1  0.0 0.0
#> 3  1.3297993  12 black 0.0 -5.1 0.1
#> 4  1.2724293  42 green 3.8  0.0 0.0

Datasets can have multi-component keys that uniquely identify each row. You can index a dataset just like a data.frame, or you can use key values to extract particular rows.

# set multi-component keys
keys(x) <- keyset(major = c("x", "x", "y", "y"),
                  minor = c(1, 2, 1, 3))

# show the data keys and values
print(x)
#>                         ════set═════
#> major minor │ age color   a    b   c
#> x         1 │  35 red   0.0 -1.3 2.8
#> x         2 │  70 blue  7.1  0.0 0.0
#> y         1 │  12 black 0.0 -5.1 0.1
#> y         3 │  42 green 3.8  0.0 0.0

# index with keys
x[dataset(major = c("y", "x"),
          minor = c(  3,   1)), ]
#>                         ════set═════
#> major minor │ age color   a    b   c
#> y         3 │  42 green 3.8  0.0 0.0
#> x         1 │  35 red   0.0 -1.3 2.8

Cite frame with the following BibTeX entry:

@Manual{,
    title = {frame: Data with Context},
    author = {Patrick O. Perry},
    year = {2018},
    note = {R package version 0.0.0},
}

The project maintainer welcomes contributions in the form of feature requests, bug reports, comments, unit tests, vignettes, or other code. If you'd like to contribute, either

This project is released with a Contributor Code of Conduct, and if you choose to contribute, you must adhere to its terms.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4