Printing the elements of a vector one per line in R

You know how R prints the elements of a vector horizontally?

> 1:5
[1] 1 2 3 4 5

Today I needed the elements printed one per line. After a bit of searching and hair-pulling, I stumbled upon the cat command:

> cat(1:5,sep="\n")
1
2
3
4
5

This is particularly useful when you need a line-by-line list of the variables in a data frame, which you can get with:

cat(names(dataframe),sep="\n")

To output the list directly to a file, use write instead of cat.