We could split the 'Groups' by 'Letters' on the unique dataset (assuming only two columns or else subset the selected columns), loop over the list and convert to nested list with as.list
lapply(with(unique(df1), split(Groups, Letters)), as.list)
-output
$A
$A[[1]]
[1] "G1"
$A[[2]]
[1] "G4"
$B
$B[[1]]
[1] "G2"
$C
$C[[1]]
[1] "G3"
$C[[2]]
[1] "G5"
If the OP wanted to create a string,
lapply(with(unique(df1), split(Groups, Letters)),
function(x) sprintf("[%s]", toString(sQuote(x, FALSE))))
-output
$A
[1] "['G1', 'G4']"
$B
[1] "['G2']"
$C
[1] "['G3', 'G5']"
Or probably, we can convert to JSON
library(jsonlite)
lapply(with(unique(df1), split(Groups, Letters)), function(x) toJSON(x))
$A
["G1","G4"]
$B
["G2"]
$C
["G3","G5"]
data
df1 <- structure(list(Groups = c("G1", "G1", "G1", "G1", "G2", "G2",
"G3", "G3", "G3", "G4", "G4", "G5"), Letters = c("A", "A", "A",
"A", "B", "B", "C", "C", "C", "A", "A", "C")),
class = "data.frame", row.names = c(NA,
-12L))