I have to 2 list such as follow:
List1 <- c("X", "Y","Z")
List2 <- c("Enable", "Status", "Quality")
I am expecting something like this:
X_Enable, X_Status,X_Quality,Y_Enable, Y_Status,Y_Quality, Z_Enable, Z_Status,Z_Quality.
Any recommendation will be helpful for me.Thank you
CodePudding user response:
Here a way to do it:
Data
List1 <- c("X", "Y","Z")
List2 <- c("Enable", "Status", "Quality")
Code
paste(rep(List1,each = length(List2)),List2,sep = "_")
Output
[1] "X_Enable" "X_Status" "X_Quality" "Y_Enable" "Y_Status" "Y_Quality" "Z_Enable" "Z_Status" "Z_Quality"
CodePudding user response:
We may use outer
c(outer(List1, List2, FUN = function(x, y) paste(x, y, sep = "_")))