Skip to content

Example of generating a named data frame? #38

@joelkuiper

Description

@joelkuiper

Love the library! But I'm a bit confused on how to easily create a data.frame with named columns, with differing types. E.g

> data.frame(x=1:10, y=rep(F, 10))
    x     y
1   1 FALSE
2   2 FALSE
3   3 FALSE
4   4 FALSE
5   5 FALSE
6   6 FALSE
7   7 FALSE
8   8 FALSE
9   9 FALSE
10 10 FALSE

I could do something like

> data.frame(x=rinteger(size=~10), y=rlogical(size=~10), z=rdouble(size=~10))
     x     y          z
1  -94 FALSE   7.124120
2  -64 FALSE -47.855625
3  -87 FALSE  -9.622184
4   -9 FALSE -28.678583
5  -78  TRUE  35.932244
6  -96  TRUE 116.449312
7  -63  TRUE  51.389978
8   65  TRUE -65.566058
9   71 FALSE 248.323594
10 -76  TRUE 138.238654

but it seems to me there must be a better way to not force the size?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions