I learnt that in R you can pass a variable number of parameters to your function with ...
I'm now trying to create a function and loop through ...
, for example to create a dataframe.
create_df <- function(...) {
for(i in ...){
... <- data.frame(...=c(1,2,3,4),column2=c(1,2,3,4))
}
}
create_df(hello,world)
I would like to create two dataframes with this code one named hello
and the other world
. One of the columns should also be named hello
and world
respectively. Thanks
This is my error:
Error in create_df(hello, there) : '...' used in an incorrect context