Using DPLYR and TIDYR, I'm trying to create a tidy version of a dataset where rows can be missing depending on the data of certain columns. I created a function that returns the rows missing (by creating them with default data) in a new tbl_df(data.frame) (I unit-tested it and it works okay with specific data).
However, when calling it from 'bind_rows', I get the following error: Error in data.frame(a, b, c,...: Object 'A' not found.
For example, my data looks like this:
A B C D E ...
a1 b1 c1 d1 e1 ...
a2 b2 c2 d2 e2 ...
...
My code looks like this:
data_tidy <- data %>%
<some other functions to clean up like 'mutuate', 'filter', etc.> %>%
brind_rows(myCustomFunction(A, B, C, D, E... ))
Any ideas what I'm doing wrong? I'm still new to R, DPLYR/TIDYR...
Note: If I remove the last call to 'bind_rows', the table is cleanup as expected with the proper A, B, C, etc. columns. I also use a 'for' loop in this specific scenario which I know might not be optimal but for now, I will work with this version so I can get it to work and then try to optimize my code (or vectorize).
Thanks!