Do you just want to concatenate two files?
txt1 <- "Lorem ipsum dolor amet polaroid hot chicken pork belly, mlkshk commodo \
typewriter excepteur. Meditation mixtape edison bulb ad venmo duis mollit \
veniam poke voluptate celiac everyday carry vape hot chicken ea."
txt2 <- "Incididunt copper mug direct trade hella taxidermy. Occupy chia in \
laborum subway tile cornhole XOXO echo park green juice try-hard sustainable. \
Put a bird on it bicycle rights hell of non chillwave blog slow-carb shoreditch \
organic ad waistcoat stumptown qui.\n"
write(txt1, "1.txt")
write(txt2, "2.txt")
# append 1.txt to 2.txt
li <- readLines("1.txt")
write(li, "2.txt", append=TRUE)
cat(readLines("2.txt"), sep="\n")
If you just want to append the first n (in this case 2) lines
write(txt1, "1.txt")
write(txt2, "2.txt")
li <- readLines("1.txt", 2)
write(li, "2.txt", append=TRUE)
cat(readLines("2.txt"), sep="\n")
To append only specific line numbers (in this case 1 and 3)
write(txt1, "1.txt")
write(txt2, "2.txt")
li <- readLines("1.txt")
write(li[c(1, 3)], "2.txt", append=TRUE)
cat(readLines("2.txt"), sep="\n")