Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ldply and the like should create the .id column as factor, preserving the order of the names in the list #137

@krlmlr

Description

@krlmlr

The .id column that is auto-generated when calling ldply on a named list seems to be stored as character vector. It should better be created as factor with the same order as given in the input list:

l <- list(b=1, a=2)
d <- ldply(l, function(i) data.frame(x=i))
levels(factor(d$.id))

Returned: "a" "b", Expected: "b" "a".

Workaround:
levels(factor(d$.id, levels=names(l)))

I'm not sure if this is easily achievable with .parallel=T, but I wouldn't mind if the order was messed up in this special case.

(plyr 1.7.1 from CRAN)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions