I have this table
Column A | Column B | Column C | Column D |
---|---|---|---|
A | x | 1 | k1 |
B | k | 2 | k2 |
C | z | 3 | k3 |
D | y | 4 | k4 |
I would like to print a txt file containing all the string in column A, divided by comma. Output: txt file --> A,B,C,D
df1 <- structure(list(ColumnA = c("A", "B", "C", "D"), ColumnB = c("x",
"k", "z", "y"), ColumnC = 1:4, ColumnD = c("k1", "k2", "k3",
"k4")), class = "data.frame", row.names = c(NA, -4L))
CodePudding user response:
We can use
cat(df1$ColumnA, sep = ",", file = "output.txt")