I want to do the print the elements of a vector line by line in R like below
1
2
3
However, when I do paste(c(1,2,3), "\n")
or paste(c(1,2,3),sep = "\n")
, the new line never gets printed out. The same thing goes for cat
as well. I always get the following:
"1" "2" "3"
I would like to know to get around this problem.
Try:
cat(paste(1:3), sep="\n")
1
2
3