I have a list containing 40 tbl_df
and am trying to combine all elements of the list into a single data frame using bind_rows()
. All elements have the same number of columns and columns have the same names. I have already generated an ID
column containing the name of each element of the list, so no need to use the ID
argument.
Upon running the command, bind_rows(list)
, I get this error:
Column
Chr
can't be converted from integer to character.
Chr in this case stands for "Chromosome" not character and these values should remain as an integer. Is dplyr automatically trying to coerce to character due to the column name being "Chr?" If so, how do I avoid dplyr doing this? It doesn't make sense that the command would be doing this, but I'm not sure what else could be going on.
FYI, this works perfectly fine when I try to combine just the first two elements of the list explicitly, i.e. bind_rows(list$element1, list$element2).
***This is my first SO question and I am new to R and coding in general. Please excuse me if I am breaking rules relating to posting. Let me know how to improve my post/question and I am happy to fix in the future.
Chr
variable, try it with a toy list. It's generally not good practice to name things with names already used for things in R, even though the capital C makes a distinction. Can you either provide a reproducible example or a sample of the list? e.g. www.stackoverflow.com/help/mcve – Scransom