I have programmed one function, which can create a data frame: (This function modifies the global environment! )
abc=function(x,y) {
if(y>=11)
stop("Noooooooooooooooooooooooooope!")
value = NA
for (i in 1:10) {
a=2+i
b=3
value[i]=(x+a)*(b*y)
}
df=data.frame(ID=(1:10),Value=(value))
assign("df",df,envir = .GlobalEnv)
View(df)
}
abc(2,9)
This function create a data frame like this:
ID Value
1 1 135
2 2 162
3 3 189
4 4 216
5 5 243
6 6 270
7 7 297
8 8 324
9 9 351
10 10 378
But now I need to create a "big" data frame in which will be more columns. For arguments abc(1,9), abc(2,9), abc(3,9) .... abc(13,9). The new data frame will be look like this:
ID Value1 Value2 Value3 ...
1 1 108 135 ...
2 2 135 162 ...
3 3 162 189 ...
4 4 189 216 ...
5 5 216 243 ...
6 6 243 ... ...
7 7 270 ... ...
8 8 297 ... ...
9 9 324 ... ...
10 10 351 ... ...
How I can make it?