Reputation: 1479
When I copy and paste the example from the Help page, this works OK:
dplyr::frame_data(
~Club, ~Compensation,
"a", 1,
"b", 2
)
Yet when I try to input my own data I get the error "Columns are not all same length".
dplyr::frame_data(
~A, ~B,
"NY", "ABc"
)
What the heck am I doing wrong? Here's another example with 2 rows of data:
soccer <- dplyr::frame_data(
~A, ~B, ~C, ~D, ~E, ~E2,
"NY", "ABc", "Anatole", "BB", 50000, 50000,
"NY", "CDe", "Saad", "D", 60000, 73750
)
Upvotes: 4
Views: 774
Reputation: 13570
In dplyr 0.4.3 frame_data
does not build rectangular tables, when nrows != ncols
. You can check more examples here. That is why you get those errors. For instance this is ok:
dplyr::frame_data(
~A, ~B,
"NY", "ABc",
"NY", "ABC"
)
Output:
Source: local data frame [2 x 2]
A B
(chr) (chr)
1 NY ABc
2 NY ABC
Apparently this issue has been fixed for the next version:
frame_data() properly constructs rectangular tables. (#1377, @kevinushey)
Upvotes: 5