You know how R prints the elements of a vector horizontally?
> 1:5  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:
To output the list directly to a file, use write instead of cat.
THANK YOU! I just spent over an hour trying to figure out how to solve a problem in Excel and was beginning to conclude that I need to learn macros/Visual Basic.
You saved me a lifetime of toil :D
Best regards from Finland,
Many thanks. That was exactly I was looking for ;)
Thanks–just what I needed today!
Thanks for this. Exactly what I needed; to get the names of the dataframe, printed one line at a time
So perfect and so simple.