DEV Community

CoderLegion
CoderLegion

Posted on β€’ Edited on β€’ Originally published at kodblems.com

1

Error in rbind(deparse.level, ...) : numbers of columns of arguments do not match

#r

πŸŽ‰ Before you dive into this article...

πŸš€ Check out our vibrant new community at CoderLegion.com!

πŸ’‘ Share your knowledge, connect with like-minded developers, and grow together.

πŸ‘‰ Click here to join now!

Problem :
I have about 25 dataframes which are essentially the frequency counts of my elements stored in the column called Elements. They all have some of the different and some of the same elements in my Elements columns so they just look like below :

dataframe called DataFrame1

Elements freq
boby 4324234
janey 433
hamy 4324
timy 22
dataframe called DataFrame1
Elements freq
boby 987
janey 223
jonny 12
jimy 98092
I am just trying to set up the table so that my Elements becomes my column and each row is my frequencies. This is so that I should be able to combine all my dataframes.

I have tried rbind on them but facing the below error:

β€œError in rbind(deparse.level, ...) : numbers of columns of arguments do not match”.

Solution :

An alternative method to the rbind + dcast technique is that the use of the tidyverse.

Please use the pipes (%>%) to first use the bind_rows() to bind all the dataframes together while simultaneously creating the dataframe id column here I just called the variable as "df". Then use the spread() to move the unique " Elements" values to become the column names and spreading your values of the "freq" across your new columns. " Elements" is the key and "freq" is your value in this case.

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

πŸ‘‹ Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Communityβ€”every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple β€œthank you” goes a long wayβ€”express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay