I'd like to use expand.grid in vector to create all the combinations of the factors in myvec, in a specific format and without duplicates. I try to:
myvec <- c("B2","B3","B4","B8","NDVI","SAVI","SIPI","SR","RGI","TVI",
"MSR","PRI","GNDVI","PSRI","GCI")
grid <- expand.grid(c(rep(myvec,length(myvec))), KEEP.OUT.ATTRS = FALSE, stringsAsFactors = FALSE)
grid
# Var1
# 1 B2
# 2 B3
# 3 B4
# 4 B8
# 5 NDVI
But, doesn't work and my desirable output is:
grid
# Var1
# 1 B2_B3
# 2 B2_B4
# 3 B2_B8
# ...
# last B2_B3_B4_B8_NDVI_SAVI_SIPI_SR_RGI_TVI_MSR_PRI_GNDVI_PSRI_GCI
Please, any help with it?