Skip to content

vec_cast.list.default() should work row wise on data frames #639

@DavisVaughan

Description

@DavisVaughan

This currently changes the size of the result because [[ is used in vec_cast.list.default()

vctrs::vec_cast(data.frame(x = 1:2), list())
#> [[1]]
#> [1] 1 2

I think this is a case where we should use vec_get(), which might be implemented to extract a single row from a data frame. (See #626)

In the mean time, we should special case data frames in vec_cast.list.default().

This breaks the following, which is how I found it.

vctrs::vec_c(data.frame(x = 1:2), .ptype = list())
#> Error in vctrs::vec_c(data.frame(x = 1:2), .ptype = list()): Internal error in `vec_assign()`: `value` should have been recycled to fit `x`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions