We can use paste
paste(paste(names(df1), collapse = ";"),
do.call(paste, c(df1, sep = ";", collapse="#")), sep="#")
-output
#[1] "input;output;aux#aa;bb;cc#a1;b1;c1#a2;b2;c2"
Or using capture.output
paste(gsub("\s+", ";", gsub("^\d+\s+", "",
trimws(capture.output(df1)))), collapse="#")
data
df1 <- structure(list(input = c("aa", "a1", "a2"), output = c("bb",
"b1", "b2"), aux = c("cc", "c1", "c2")), class = "data.frame",
row.names = c(NA,
-3L))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…