How to make smart bind work with do.call, I am getting error " argument "args" is missing, with no default"

I have to combine 10 different sets into one using smart bind because it has different number of columns but I am getting the following error
data1 <- do.call(smartbind(data1,data2,data3,data4,data5,data6,data7,data8,data9,fill = 0 ))
Error in do.call(smartbind(data1, data2, data3, data4, data5, data6, data7, :
argument "args" is missing, with no default

Welcome to the community!

I don't know what package has the function smartbind, but do.call doesn't work this way. You're supposed to use it in the form do.call(function_name, list(argument_1, argument_2, ...)).

If you want more specific pointers, can you please provide a REPRoducible EXample of your problem? It provides more specifics of your problem, and it helps others to understand what problem you are facing.

If you don't know how to do it, take a look at this thread:

1 Like

Ok, so let me put it this way. I have 10 data sets to combine named as data1, data2, data3 ......data10. But the problem is that all of them have different number of columns, some of them have 37 & the others have 38 columns. So rbind doesn't works if your data have different number of columns. Smart bind works but doing it one by one would take a lot of time. So I want to call them and bind them all at once row wise.
I believe we can do it by combining do.call function with smart bind but when I am trying to do it this way
data1 <- do.call(smartbind(data1,data2,data3,data4,data5,data6,data7,data8,data9,fill = 0 ))
it gives the following error:
Error in do.call(smartbind(data1, data2, data3, data4, data5, data6, data7, :
argument "args" is missing, with no default

Hi,

@Yarnabrina did provide you the correct syntax of the do.call function, you just need to implement it :slight_smile:

library(gtools)
#EXAMPLE
df1 = data.frame(x = 1:10, y = runif(10), z = LETTERS[1:10])
df2 = data.frame(x = 1:10, y = runif(10), z = LETTERS[1:10])
df3 = data.frame(x = 1:10, y = runif(10), z = LETTERS[1:10])

do.call(smartbind, list(df1, df2, df3, fill = 0))

Note how the do.call requires the first argument to be the function, the second is the list of arguments that go inside the function you're calling.

Please remember to create a reprex next time so it's easier to understand the question and generate the error ourselves.

Hope this helps,
PJ

Thanks a lot, it worked. :slightly_smiling_face:

@Yarnabrina, thanks it worked:slightly_smiling_face:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.