Am struggling with operation as my datasets are very large and i have provided an example of what i want.
I have two dataframes.
df1 - contains sampling-derived iterations for each parameter of a variable defined as the column name (10,000 rows)
df2 - contains the actual value of each of the variable defined as the column name (4,000 rows)
I want a df3 which is effectively the multiplication of each row of df2 by df1 and would therefore be 4000*10000 rows
As a short example i have provided a minimal example of df1 and df2. I have provided the output that i would be looking at shown in df3.
df1 <- structure(list(intercept = c(3.4, 3.6, 3.7), age = c(0.08, 0.05,
0.06), male = c(0.07, 0.06, 0.07)), class = "data.frame", row.names = c(NA,
-3L))
df2 <- structure(list(id = structure(1:2, .Label = c("a", "b"), class = "factor"),
intercept = c(1L, 1L), age = c(40L, 45L), male = 1:0), class = "data.frame", row.names = c(NA,
-2L))
df3 <- structure(list(id = structure(c(1L, 1L, 1L, 2L, 2L, 2L), .Label = c("a",
"b"), class = "factor"), intercept = c(3.4, 3.6, 3.7, 3.4, 3.6,
3.7), age = c(3.2, 2, 2.4, 3.6, 2.25, 2.7), male = c(0.07, 0.06,
0.07, 0, 0, 0)), class = "data.frame", row.names = c(NA, -6L))
Can somebody point me to an efficient way to do this in R?