I am a relative newbie to R, and now I am very close to ending up with a rather long script thanks to everyone who has helped me so far at different stages. I have one more thing that I'm stuck with. I simplified this question:
Dataset1 ax ay 1 3 2 4 Dataset2 bx by 5 7 6 8 A <- dataset1 B <- dataset2 a <- 2
(my data sets will vary in the number of columns, and therefore I need to be able to change this coefficient)
I need this answer in any order (i.e. all possible combinations of two columns, one from each of the two datasets), as it is or equivalent.
[[1]] 1 5 2 6 [[2]] 1 7 2 8 [[3]] 3 5 4 6 [[4]] 3 7 4 8
But I do not understand. I tried a bunch of things, and the closest thing to what I want was with this:
i <- 1 for( i in 1:a ) { e <- lapply(B, function(x) as.data.frame(cbind(A, x))) print(e) i <- i+1 }
Close, yes. I can accept the answer and do some kind of fake and a subset, but it is not, and there should be an easy way to do it. I have not seen anything like this in my searches. Any help is greatly appreciated.
source share