Dplyr frame_data errors with "Columns are not the same"

When I copy and paste the example from the help page, this works fine:

dplyr::frame_data( 
   ~Club, ~Compensation,
   "a",   1,
   "b",   2
)

But when I try to enter my own data, I get the error message "Columns are not the same."

dplyr::frame_data( 
   ~A,    ~B,
   "NY",  "ABc"
)

What the hell am I doing wrong? Here is another example with two 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
)
+4
source share
1 answer

In dplyr 0.4.3 frame_datadoes not create rectangular tables when nrows != ncols. Here you can check out a few examples. That is why you get these errors. For example, this is normal:

dplyr::frame_data( 
  ~A,    ~B,
  "NY",  "ABc",
  "NY", "ABC"
)

Exit:

Source: local data frame [2 x 2]

      A     B
  (chr) (chr)
1    NY   ABc
2    NY   ABC

This problem seems to be fixed for the next version :

frame_data() . (# 1377, @kevinushey)

+5

Source: https://habr.com/ru/post/1617537/


All Articles